Documents¶
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.
-
__raw__
¶ Dict with raw data from mongo
-
__cache__
¶ Dict with cached objects, casted with fields
-
__changed__
¶ Dict with changed objects
-
__data__
¶ Deprecated! For backward compatibility only!
Old way to storing data in documents. Now equal to
__raw__
.
-
__debug_print__
()¶ Print debug information.
-
__fake__
(values, faker, depth)¶ Fake data customizer.
-
-
class
yadm.documents.
Document
(**kwargs)¶ Class for build first level documents.
-
__collection__
¶ Name of MongoDB collection
-
_id
¶ Mongo object id (
bson.ObjectId
)
-
__db__
¶ Internal attribute contain instance of
yadm.database.Database
for realizeyadm.fields.references.ReferenceField
. It bind inyadm.database.Database
oryadm.queryset.QuerySet
.
-
__qs__
¶ Documents gets from this queryset
-
-
class
yadm.documents.
DocumentItemMixin
¶ Mixin for custom all fields values, such as
EmbeddedDocument
,yadm.fields.containers.Container
.-
__parent__
¶ Parent object.
assert doc.embedded_doc.__parent__ is doc assert doc.list[13].__parent__ is doc.list
-
__name__
¶ assert doc.list.__name__ == 'list' assert doc.list[13].__name__ == 13
-
__db__
¶ Database object.
assert doc.f.l[0].__db__ is doc.__db__
-
__document__
¶ Root document.
assert doc.f.l[0].__document__ is doc
-
__field_name__
¶ Dotted field name for MongoDB opperations, like as $set, $push and other...
assert doc.f.l[0].__field_name__ == 'f.l.0'
-
__get_value__
(document)¶ Get value from document with path to self.
-
__path__
¶ Path to root generator.
assert list(doc.f.l[0].__path__) == [doc.f.l[0], doc.f.l, doc.f]
-
__path_names__
¶ Path to root generator.
assert list(doc.f.l[0].__path__) == [0, 'l', 'f']
-
__qs__
¶ Queryset object.
-
__weakref__
¶ list of weak references to the object (if defined)
-
-
class
yadm.documents.
EmbeddedDocument
(**kwargs)¶ Class for build embedded documents.