A module for accessing MongoDB via PyMongo, called data.pymongo will be created.
There are two classes to be implemented:
The GenericDAO Class
[ ] implemented
The class will be given an existing pymongo object and the name of the database query.
One instance can be shared by multiple objects (as the normal pymongo object).
The class itself won't initialize the connection!
Each of the methods in the class that accesses the database can throw DataSourceError if the database or collection is not accessible.
The class will have the following methods:
[x] find_record(collection_name, query) that returns the first record mathing the given Mongo Query.
[x] nothing found => return None
[x] another error => throw DataSourceError
[x] find_records(collection_name, query, sort_by=None, sort_direction=None, start=0, limit=None) that will return a cursor of objects matching the given criteria.
[x] nothing found => return empty datastorage.Cursor
A module for accessing MongoDB via PyMongo, called
data.pymongo
will be created. There are two classes to be implemented:The GenericDAO Class
The class will be given an existing pymongo object and the name of the database query. One instance can be shared by multiple objects (as the normal pymongo object). The class itself won't initialize the connection!
Each of the methods in the class that accesses the database can throw
DataSourceError
if the database or collection is not accessible.The class will have the following methods:
find_record(collection_name, query)
that returns the first record mathing the given Mongo Query.None
DataSourceError
find_records(collection_name, query, sort_by=None, sort_direction=None, start=0, limit=None)
that will return a cursor of objects matching the given criteria.datastorage.Cursor
DataSourceError