|
@@ -33,7 +33,7 @@ class MongoDbDatasource(object):
|
33
|
33
|
# @return list
|
34
|
34
|
# @todo Implement the relations
|
35
|
35
|
def select(self, target, field_list, filters, rel_filters=None, order=None, group=None, limit=None, offset=0, instanciate=True):
|
36
|
|
- collection_name = object_collection_name(target.__class__)
|
|
36
|
+ collection_name = object_collection_name(target)
|
37
|
37
|
collection = self.database[collection_name]
|
38
|
38
|
query_filters = parse_query_filters(filters)
|
39
|
39
|
query_result_ordering = parse_query_order(order) if order is not None else None
|
|
@@ -82,7 +82,7 @@ class MongoDbDatasource(object):
|
82
|
82
|
def delete(self, target, uid):
|
83
|
83
|
if isinstance(uid, dict):
|
84
|
84
|
uid = [uid]
|
85
|
|
- collection_name = object_collection_name(target.__class__)
|
|
85
|
+ collection_name = object_collection_name(target)
|
86
|
86
|
collection = self.database[collection_name]
|
87
|
87
|
result = collection.delete_many(uid)
|
88
|
88
|
return result.deleted_count
|
|
@@ -96,7 +96,7 @@ class MongoDbDatasource(object):
|
96
|
96
|
def update(self, target, uids, **datas):
|
97
|
97
|
if not isinstance(uids, list):
|
98
|
98
|
uids = [uids]
|
99
|
|
- collection_name = object_collection_name(target.__class__)
|
|
99
|
+ collection_name = object_collection_name(target)
|
100
|
100
|
collection = self.database[collection_name]
|
101
|
101
|
results = collection.update_many({'uid': {'$in': uids}}, datas)
|
102
|
102
|
return results.modified_count()
|
|
@@ -107,7 +107,7 @@ class MongoDbDatasource(object):
|
107
|
107
|
# @return bool
|
108
|
108
|
# @TODO Implement the error management
|
109
|
109
|
def insert(self, target, **datas):
|
110
|
|
- collection_name = object_collection_name(target.__class__)
|
|
110
|
+ collection_name = object_collection_name(target)
|
111
|
111
|
collection = self.database[collection_name]
|
112
|
112
|
result = collection.insert_one(datas)
|
113
|
113
|
return len(result.inserted_id)
|
|
@@ -118,7 +118,7 @@ class MongoDbDatasource(object):
|
118
|
118
|
# @return list : list of the inserted records' ids
|
119
|
119
|
# @TODO Implement the error management
|
120
|
120
|
def insert_multi(self, target, datas_list):
|
121
|
|
- collection_name = object_collection_name(target.__class__)
|
|
121
|
+ collection_name = object_collection_name(target)
|
122
|
122
|
collection = self.database[collection_name]
|
123
|
123
|
result = collection.insert_many(datas_list)
|
124
|
124
|
return len(result.inserted_ids)
|