|
@@ -105,9 +105,18 @@ class MongoDbDataSource(object):
|
105
|
105
|
return result.deleted_count
|
106
|
106
|
|
107
|
107
|
## @brief updates one or a list of records
|
108
|
|
- # @todo to be implemented
|
109
|
|
- def update(self, target_cls, uid, **datas):
|
110
|
|
- pass
|
|
108
|
+ # @param target_cls Emclass : class of the object to insert
|
|
109
|
+ # @param uids list : list of uids to update
|
|
110
|
+ # @param datas dict : datas to update (new values)
|
|
111
|
+ # @return int : Number of updated records
|
|
112
|
+ # @todo check if the values need to be parsed
|
|
113
|
+ def update(self, target_cls, uids, **datas):
|
|
114
|
+ if not isinstance(uids, list):
|
|
115
|
+ uids = [uids]
|
|
116
|
+ collection_name = utils.object_collection_name(target_cls.__class__)
|
|
117
|
+ collection = self.database[collection_name]
|
|
118
|
+ results = collection.update_many({'uid': {'$in': uids}}, datas)
|
|
119
|
+ return results.modified_count()
|
111
|
120
|
|
112
|
121
|
## @brief Inserts a record in a given collection
|
113
|
122
|
# @param target_cls Emclass : class of the object to insert
|