ming.base module

Ming Base module. Good stuff here.

ming.base.Missing = <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)

Bases: object

Python class proxying a MongoDB cursor, constructing and validating objects that it tracks

all()
count()
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: ming.base.Object

classmethod make(data, **kwargs)

Kind of a virtual constructor

class ming.declarative._DocumentMeta

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 and sparse keyword arguments are also consumed by Field 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
collection
count(*args, **kwargs)
distinct(*args, **kwargs)
drop_indexes(*args, **kwargs)
ensure_index(*args, **kwargs)
ensure_indexes(*args, **kwargs)
fields
find(*args, **kwargs)
find_and_modify(*args, **kwargs)
find_by(*args, **kwargs)
get(*args, **kwargs)
group(*args, **kwargs)
index_information(*args, **kwargs)
inline_map_reduce(*args, **kwargs)
make(data, allow_extra=False, strip_extra=True)
map_reduce(*args, **kwargs)
migrate()

Load each doc in the collection and immediately save it

polymorphic_on
polymorphic_registry
remove(*args, **kwargs)
update_partial(*args, **kwargs)
with_session(session)

Return a Manager with an alternate session

class ming.metadata._InstanceManager(mgr, inst)

Bases: object

delete(*args, **kwargs)
increase_field(*args, **kwargs)
insert(*args, **kwargs)
save(*args, **kwargs)
set(*args, **kwargs)
upsert(*args, **kwargs)
class ming.metadata._ManagerDescriptor(manager)

Bases: object

engine
class ming.base.Object

Bases: dict

Dict providing object-like attr access

classmethod from_bson(bson)
make_safe()