The objectstorage module allows you to save ordinary Python objects directly into PouchDB. The (de)serializing is handled by the jsonpickle module.
>>> from pouchdb.objectstorage import load, store
>>> from jsonpickle._samples import Thing
>>>
>>> env = setup()
>>> db = env.PouchDB("objectstorage_test")
>>> thingy = Thing("abc")
>>>
>>> store(thingy, db, "the_id")
Thing("abc")
>>> new_thingy = load(db, "the_id")
>>> print new_thingy.name
abc
>>>
>>> env.destroy("objectstorage_test")
Stores obj into db.
Parameters: |
|
---|---|
Returns: | obj – the same object as the parameter on which obj.id and obj.rev will have been set. |
Loads an earlier under id stored object from db.
Parameters: |
|
---|---|
Returns: | the earlier stored object. |