pouchdb-patch-data
Store and read object patches (with metadata) in insert order. Based on level-patch-data.
Example
var assert =var Pouch =var Patch =var db =var patch =patch
See tests for more examples.
Methods
var patch = Patch(db, opts)
db
: an instance ofpouchdb
to store patches and data.opts.namespaceField
: the field to use to store thenamespace
. default:namespace
opts.patchField
: the field to use to store thepatch
. default:patch
patch.add(namespace, patch, meta, callback)
alias: addPatch
namespace
: the string to identify this collections of patches. This module is designed for use with patcher patches for a single object per uniquenamespace
patch
: the object to store as the patchmeta
: key/value pairs to store with this patch. Note: the keysopts.namespaceField
, andopts.patchField
will be overwritten if set.callback
: receives two arguments,err
which is only set if an error occurs andcommit
, which is the patch and its metadata exactly as it was saved.
patch.get(namespace, since, callback)
aliases: patches
, getPatches
Callback is called with any error and a list of commits in insert order.
namespace
: the collection of patches to read. patches will be streamed in the order inserted.since
: optional. pass the_id
of the commit to read commits since. The commit with_id === since
will not be returned, only all commits after it.
License
MIT