nordlys.core.storage.mongo module¶
Mongo¶
Tools for working with MongoDB.
Authors: | Krisztian Balog, Faegheh Hasibi |
---|
-
class
nordlys.core.storage.mongo.
Mongo
(host, db, collection)[source]¶ Bases:
object
Manages the MongoDB connection and operations.
-
ID_FIELD
= '_id'¶
-
append_dict
(doc_id, field, dictkey, value)[source]¶ Appends the value to a given field that stores a dict. If the dictkey is already in use, the value stored there will be overwritten.
Parameters: - doc_id – document id
- field – field
- dictkey – key in the dictionary
- value – value to be increased by
-
append_list
(doc_id, field, value)[source]¶ Appends the value to a given field that stores a list. If the field does not exist yet, it will be created. The value should be a list.
Parameters: - doc_id – document id
- field – field
- value – list, a value to be appended to the current list
-
append_set
(doc_id, field, value)[source]¶ Adds a list of values to a set. If the field does not exist yet, it will be created. The value should be a list.
Parameters: - doc_id – document id
- field – field
- value – list, a value to be appended to the current list
-
find_all
(no_timeout=False)[source]¶ Returns a Cursor instance that allows us to iterate over all documents.
-
inc_in_dict
(doc_id, field, dictkey, value=1)[source]¶ Increments a value that is inside a dict.
Parameters: - doc_id – document id
- field – field
- dictkey – key in the dictionary
- value – value to be increased by
-