tori.db.repository¶
Author: | Juti Noppornpitak <jnopporn@shiroyuki.com> |
---|---|
Status: | Stable |
-
class
tori.db.repository.
Repository
(session, representing_class)¶ Repository (Entity AbstractRepository) for Mongo DB
Parameters: - session (tori.db.session.Session) – the entity manager
- representing_class (type) – the representing class
A repository may automatically attempt to create an index if
auto_index()
define the auto-index flag. Please note that the auto-index feature is only invoked when it tries to use a criteria with sorting or filtering with a certain type of conditions.-
auto_index
(auto_index)¶ Enable the auto-index feature
Parameters: auto_index (bool) – the index flag
-
count
(criteria)¶ Count the number of entities satisfied the given criteria
Parameters: criteria (tori.db.criteria.Query) – the search criteria Return type: int
-
find
(criteria, force_loading=False)¶ Find entity with criteria
Parameters: - criteria (tori.db.criteria.Query) – the search criteria
- force_loading (bool) – the flag to force loading all references behind the proxy
Returns: the result based on the given criteria
Return type: object or list of objects
-
index
(index, force_index=False)¶ Index data
Parameters: - index (list, tori.db.entity.Index or str) – the index
- force_index (bool) – force indexing if necessary
-
name
¶ Collection name
Return type: str
-
new
(**attributes)¶ Create a new document/entity
Parameters: attributes – attribute map Returns: object Note
This method deal with data mapping.
-
new_criteria
(alias='e')¶ Create a criteria
Return type: tori.db.criteria.Query
-
session
¶ Session
Return type: tori.db.session.Session
-
setup_index
()¶ Set up index for the entity based on the
entity
andlink
decorators