def update_resource(cls, dryrun_id, resource_id, dryrun_data):
"""
Register a resource update with a specific query that sets the dryrun_data and decrements the todo counter, only
if the resource has not been saved yet.
"""
entry_uuid = uuid.uuid5(dryrun_id, resource_id)
resource_key = "resources.%s" % entry_uuid
query = {"_id": dryrun_id, resource_key: {"$exists": False}}
update = {"$inc": {"todo": int(-1)}, "$set": {resource_key: cls._value_to_dict(dryrun_data)}}
yield cls._coll.update_one(query, update)
评论列表
文章目录