sync update: + data provider; refactoring; documents update

This commit is contained in:
tmshv committed 2016-08-05 02:04:06 +03:00
1 parent 144e69e6c4
commit 927674e53e
9 files changed
+311 -229

No files matched your search

-45
View File
@@ -107,48 +107,3 @@ create_post_from_image_list = lambda images: markdown(
images
))
)
class Sync:
def __init__(self):
super().__init__()
self.collection = None
def read(self, document):
if isinstance(document, list):
return lmap(self.read, document)
q = {'id': document['id']}
try:
return self.collection.find_one(q)
except ValueError:
pass
return None
def update(self, document):
if isinstance(document, list):
return lmap(self.update, document)
q = {'id': document['id']}
try:
self.collection.update_one(q, {'$set': document}, upsert=True)
return self.read(document)
except ValueError:
pass
return None
def compile(self, document):
return document
def query(self, q):
return self.collection.find(q)
def delete(self, q):
return self.collection.find_one_and_delete(q)
def create_id(self, document):
return None
def create_hash(self, document):
return None