API¶
Collection¶
-
class
mongorest.collection.Collection(document=None)[source]¶ Base Class for Collections.
-
after_validation()[source]¶ Callback called after the validation of a document occurs. Should return None to allow the next callbacks to run. If anything else is returned the next callbacks are not called and __init__ is finished
-
classmethod
aggregate(*args, **kwargs)[source]¶ Returns the document dicts returned from the Aggregation Pipeline
-
before_delete()[source]¶ Callback called before a delete occurs. Should return None to allow the delete to happen. If anything else is returned the delete will not occur and the returned value will be the return of the delete function
-
before_insert()[source]¶ Callback called before an insert occurs. Should return None to allow the insert to happen. If anything else is returned the insert will not occur and the returned value will be the return of the insert function
-
before_update(old)[source]¶ Callback called before an update occurs. Should return None to allow the update to happen. If anything else is returned the update will not occur and the returned value will be the return of the update function
-
before_validation()[source]¶ Callback called before the validation of a document occurs. Should return None to allow the validation process to happen. If anything else is returned the validation is not executed and __init__ is finished
-
document¶ Returns the document
-
classmethod
documents(filter=None, **kwargs)[source]¶ Returns a list of Documents if any document is filtered
-
errors¶ Returns the validation errors
-
classmethod
find_one(*args, **kwargs)[source]¶ Returns one document dict if one passes the filter. Returns None otherwise.
-
classmethod
get(filter=None, **kwargs)[source]¶ Returns a Document if any document is filtered, returns None otherwise
-
insert(*args, **kwargs)[source]¶ Saves the Document to the database if it is valid. Returns errors otherwise.
-
classmethod
insert_many(*args, **kwargs)[source]¶ Inserts a list of documents into the Collection and returns their _ids
-
classmethod
insert_one(*args, **kwargs)[source]¶ Inserts a document into the Collection and returns its _id
-
is_valid¶ Returns True if no validation errors have been found, False otherwise.
-
classmethod
replace_one(*args, **kwargs)[source]¶ Replaces a document that passes the filter. Will upsert a new document if upsert=True and no document is filtered
-
update(*args, **kwargs)[source]¶ Updates the document with the given _id saved in the collection if it is valid. Returns errors otherwise.
-