ming.base
module¶
Ming Base module. Good stuff here.
- ming.base.Missing = ()¶
This is the value that Missing fields in MongoDB documents receive.
Functions¶
- ming.base._safe_bson(obj, _no_warning=False)¶
Verify that the obj is safe for bsonification (in particular, no tuples or Decimal objects
Classes¶
- class ming.base.Cursor(cls, cursor, allow_extra=True, strip_extra=True, find_spec=None)¶
Bases:
object
Python class proxying a MongoDB cursor, constructing and validating objects that it tracks
- all()¶
- count()¶
This method, although deprecated by pymongo, is kept for backcompat with existing code. It is inaccurate when used with a cursor that has been limited or skipped. However, this behavior is consistent with previous pymongo (3.X) and mongo shell (4.X) behavior.
- distinct(*args, **kwargs)¶
- first()¶
- hint(index_or_name)¶
- limit(limit)¶
- next()¶
- one()¶
- rewind()¶
- skip(skip)¶
- sort(*args, **kwargs)¶
- class ming.metadata._Document(data=None, skip_from_bson=False)¶
Bases:
Object
,EncryptedMixin
- classmethod make(data, **kwargs)¶
Kind of a virtual constructor
- class ming.declarative._DocumentMeta(classname, bases, dct, **kwargs)¶
Bases:
type
- mro()¶
Return a type’s method resolution order.
- class ming.metadata.Field(*args, **kwargs)¶
Bases:
object
Represents a Field in a MongoDB Document
It accepts one or two positional arguments and any number of keyword arguments.
If only one positional argument is provided that is considered to be the schema of the Field which is one of the types available in
ming.schema
module.If two positional arguments are provided the first is considered being the name of the field inside the MongoDB Document and the second is still the schema type.
The
index
,unique
andsparse
keyword arguments are also consumed byField
to automatically create an index for the field.Additional arguments are just forwarded to Schema constructor if the provided schema argument is not already an instance. So see the classes declared in
ming.schema
for details on the other available keyword arguments.
- class ming.metadata._ClassManager(cls, collection_name, session, fields, indexes, polymorphic_on=None, polymorphic_identity=None, polymorphic_registry=None, version_of=None, migrate=None, before_save=None)¶
Bases:
object
- InstanceManagerClass¶
alias of
_InstanceManager
- add_index(idx)¶
- aggregate(*args, **kwargs)¶
- before_save = None¶
- property collection¶
- count(*args, **kwargs)¶
- create_index(*args, **kwargs)¶
- distinct(*args, **kwargs)¶
- drop_indexes(*args, **kwargs)¶
- ensure_index(*args, **kwargs)¶
- ensure_indexes(*args, **kwargs)¶
- property fields¶
- find(*args, **kwargs)¶
- find_by(*args, **kwargs)¶
- find_one_and_delete(*args, **kwargs)¶
- find_one_and_replace(*args, **kwargs)¶
- find_one_and_update(*args, **kwargs)¶
- get(*args, **kwargs)¶
- index_information(*args, **kwargs)¶
- make(data, allow_extra=False, strip_extra=True)¶
- migrate()¶
Load each doc in the collection and immediately save it
- property polymorphic_on¶
- property polymorphic_registry¶
- remove(*args, **kwargs)¶
- update_partial(*args, **kwargs)¶
- with_session(session)¶
Return a Manager with an alternate session