Basic documents classes for build models.

class User(Document):
    __collection__ = 'users'

    first_name = fields.StringField()
    last_name = fields.StringField()
    age = fields.IntegerField()

All fields placed in yadm.fields package.

class yadm.documents.MetaDocument(cls, name, bases, cls_dict)

Metaclass for documents.

class yadm.documents.BaseDocument(**kwargs)

Base class for all documents.


Dict with raw data from mongo


Dict with cached objects, casted with fields


Dict with changed objects


Deprecated! For backward compatibility only!

Old way to storing data in documents. Now equal to __raw__.


Print debug information.

__fake__(values, faker, depth)

Fake data customizer.

class yadm.documents.Document(**kwargs)

Class for build first level documents.


Name of MongoDB collection


Default projection for querysets


Mongo object id (bson.ObjectId)


Alias for _id for simply use


Internal attribute contain instance of yadm.database.Database for realize yadm.fields.references.ReferenceField. It bind in yadm.database.Database or yadm.queryset.QuerySet.


Documents gets from this queryset

class yadm.documents.DocumentItemMixin

Mixin for custom all fields values, such as EmbeddedDocument, yadm.fields.containers.Container.


Parent object.

assert doc.embedded_doc.__parent__ is doc
assert doc.list[13].__parent__ is doc.list
assert doc.list.__name__ == 'list'
assert doc.list[13].__name__ == 13

Database object.

assert doc.f.l[0].__db__ is doc.__db__

Root document.

assert doc.f.l[0].__document__ is doc

Dotted field name for MongoDB opperations, like as $set, $push and other…

assert doc.f.l[0].__field_name__ == 'f.l.0'

Get value from document with path to self.


Path to root generator.

assert list(doc.f.l[0].__path__) == [doc.f.l[0], doc.f.l, doc.f]

Path to root generator.

assert list(doc.f.l[0].__path__) == [0, 'l', 'f']

Queryset object.


list of weak references to the object (if defined)

class yadm.documents.EmbeddedDocument(**kwargs)

Class for build embedded documents.