Sync util big update

This commit is contained in:
tmshv committed 2016-02-27 16:19:08 +03:00
1 parent 1e80bae401
commit 40321327d6
30 files changed
+1001 -159

No files matched your search

+20
View File
@@ -0,0 +1,20 @@
from db import db
from utils.fn import lmap
def sync_image(record):
if isinstance(record, list):
return lmap(
sync_image,
record
)
q = {'hash': record['hash']}
try:
db().images.update_one(q, {'$set': record}, upsert=True)
i = db().images.find_one({'hash': record['hash']})
return i
except ValueError:
pass
return None