passerine.db.repository

Note

This page is automatically generated. If you don’t see anything, this means this sub-module is not meant to be used. If you really want to know what it is, please check out the source code at passerine/db/repository.py.

Author:Juti Noppornpitak <jnopporn@shiroyuki.com>
Status:Stable
class passerine.db.repository.Repository(session, representing_class)

Repository (Entity AbstractRepository) for Mongo DB

Parameters:

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 (passerine.db.criteria.Query) – the search criteria
Return type:int
filter(condition={}, force_loading=False)

Shortcut method for :method:`find`.

filter_one(condition={}, force_loading=False)

Shortcut method for :method:`find`.

find(criteria=None, force_loading=False)

Find entity with criteria

Parameters:
  • criteria (passerine.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, passerine.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:passerine.db.criteria.Query
session

Session

Return type:passerine.db.session.Session
setup_index()

Set up index for the entity based on the entity and link decorators