|
@@ -56,17 +56,26 @@ class MongoDbDataSource(object):
|
56
|
56
|
return (connection_args['login'], urllib.quote_plus(connection_args['password']), connection_args['host'],
|
57
|
57
|
connection_args['port'], connection_args['dbname'])
|
58
|
58
|
|
59
|
|
-
|
60
|
59
|
## @brief returns a selection of documents from the datasource
|
61
|
60
|
# @param target_cls Emclass
|
62
|
61
|
# @param field_list list
|
|
62
|
+ # @param filters list : List of filters
|
|
63
|
+ # @param rel_filters list : List of relational filters
|
|
64
|
+ # @param order list : List of column to order. ex: order = [('title', 'ASC'),]
|
|
65
|
+ # @param group list : List of tupple representing the column to group together. ex: group = [('title', 'ASC'),]
|
|
66
|
+ # @param limit int : Number of records to be returned
|
|
67
|
+ # @param offset int: used with limit to choose the start record
|
|
68
|
+ # @param instanciate bool : If true, the records are returned as instances, else they are returned as dict
|
|
69
|
+ # @return list
|
|
70
|
+ # @todo Implement the grouping
|
|
71
|
+ # @todo Implement the relations
|
63
|
72
|
def select(self, target_cls, field_list, filters, rel_filters=None, order=None, group=None, limit=None, offset=0,
|
64
|
73
|
instanciate=True):
|
65
|
74
|
collection_name = utils.object_collection_name(target_cls.__class__)
|
66
|
75
|
collection = self.database[collection_name]
|
67
|
76
|
query_filters = utils.parse_query_filters(filters)
|
68
|
77
|
query_result_ordering = utils.parse_query_order(order) if order is not None else None
|
69
|
|
- results_field_list = None if len(field_list) == 0 else field_list # TODO On peut peut-être utiliser None dans les arguments au lieu d'une liste vide
|
|
78
|
+ results_field_list = None if len(field_list) == 0 else field_list
|
70
|
79
|
limit = limit if limit is not None else 0
|
71
|
80
|
cursor = collection.find(
|
72
|
81
|
filter=query_filters,
|
|
@@ -95,8 +104,9 @@ class MongoDbDataSource(object):
|
95
|
104
|
result = collection.delete_many(uid)
|
96
|
105
|
return result.deleted_count
|
97
|
106
|
|
|
107
|
+ ## @brief updates one or a list of records
|
|
108
|
+ # @todo to be implemented
|
98
|
109
|
def update(self, target_cls, uid, **datas):
|
99
|
|
-
|
100
|
110
|
pass
|
101
|
111
|
|
102
|
112
|
## @brief Inserts a record in a given collection
|