atomdb.nosql module¶
Copyright (c) 2018-2022, CodeLV.
Distributed under the terms of the MIT License.
The full license is in the file LICENSE.text, distributed with this software.
Created on Jun 12, 2018
- class atomdb.nosql.NoSQLDatabaseProxy[source]¶
Bases:
atom.atom.Atom
A proxy to the collection which holds a cache of model objects.
- cache¶
Object cache
- table¶
Database handle
- class atomdb.nosql.NoSQLModel[source]¶
Bases:
atomdb.base.Model
An atom model that can be serialized and deserialized to and from MongoDB.
- objects: ClassVar[atomdb.base.ModelManager]¶
Handles database access
- async classmethod restore(state, force=False)[source]¶
Restore an object from the database. If the object is cached, use that instead.
- serializer: ClassVar[atomdb.base.ModelSerializer] = <atomdb.nosql.NoSQLModelSerializer object>¶
Handles encoding and decoding
- class atomdb.nosql.NoSQLModelManager[source]¶
Bases:
atomdb.base.ModelManager
A descriptor so you can use this somewhat like Django’s models. Assuming your using motor or txmongo.
MyModel.objects.find_one({‘_id’:’someid})
- database¶
Used to access the database
- proxies¶
Table proxy cache
- class atomdb.nosql.NoSQLModelSerializer[source]¶
Bases:
atomdb.base.ModelSerializer
Handles serializing and deserializing of Model subclasses. It will automatically save and restore references where present.
- flatten_object(obj, scope)[source]¶
Serialize a model for entering into the database
- obj: Model
The object to unflatten
- scope: Dict
The scope of references available for circular lookups
- result: Object
The flattened object
- async get_object_state(obj, state, scope)[source]¶
Lookup the state needed to restore the given object id and class.
- obj: Model
The object created by get_or_create
- state: Dict
Unflattened state of object to restore
- scope: Dict
Scope of objects available when flattened
- result: Any
The model state needed to restore this object
- async get_or_create(cls, state, scope)[source]¶
Restore an object from the database. If the object is cached, use that instead.
- registry¶
Store all registered models