new IDocument(options)
Represents a document with caching and local+remote change notifications
Name | Type | Description | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options | object | Properties
|
- Source
Extends
- EventEmitter
Members
(static) cleanData :object
document data with no library added fields
- object
- Source
(static) data :object
entire document
- object
- Source
(static) Document :IDocument
- IDocument
(static) hash :object
hash of document.data
using sha256
- object
- Source
(static) id :string
Document mongo-id
- string
- Source
(static) idObj :IdObj
Document id object
- Source
(static) idString :sting
Document id string in format <type>:<mongo-id>
- sting
- Source
(static) revision :string
Document revision string
- string
- Source
(static) type :string
Document type string
- string
- Source
Methods
(async, static) create(party, document)
Name | Type | Description |
---|---|---|
party | moddule:Party. | |
document | * |
- Source
(static) getData()
- Source
(async, static) mergeData(input) → {object}
Name | Type | Description |
---|---|---|
input | object |
- Source
- Type:
- object
(async, static) pull(flushcache)
Name | Type | Description |
---|---|---|
flushcache | boolean | Update local cache as well |
- Source
(async, static) remove()
- Source
(async, static) save()
- Source
(async, static) setData(input) → {object}
Name | Type | Description |
---|---|---|
input | object |
- Source
- Type:
- object
(static) unwatch(cbopt)
Stop watching for remote document changes
Name | Type | Attributes | Description |
---|---|---|---|
cb | function | <optional> | Optional Change event callback function |
- Source
(async, static) watch(autopull, flushcache, cbopt)
Name | Type | Attributes | Description |
---|---|---|---|
autopull | boolean | ||
flushcache | boolean | ||
cb | function | <optional> | Optional Change event callback function |
- Source
(static) watchField(field, valueopt, cb)
Watch a field for changes. If value
is supplied watches for field and value
to match.
Name | Type | Attributes | Description |
---|---|---|---|
field | string | Field path to watch for changes | |
value | * | <optional> | Match value |
cb | function | Callback function |
- Source
Events
change
Document change Event - This is event is triggered when a document has been modified on the remote service
- object
- Source
create
Document create Event - This event is triggered after a document has been created and applied to the backing cache of Document.data
. If Document.followcache
is true the document doc
has also accepted the change.
- module:Party.
IDocument. Event
- Source
field
Field change event. This is emitted as field.[FIELD_PATH]
- object
Name | Type | Description |
---|---|---|
doc | The changed document | |
field | The changed FIELDPATH | |
old | The old field value | |
new | The new field value | |
expected | The expected field value |
- Source
remove
Document remove Event - This event is triggered after a document has been removed and applied to the backing cache of Document.data
. If Document.followcache
is true the document doc
has also accepted the change.
- module:Party.
IDocument. Event
- Source
update
Document update Event - This event is triggered after a change has been applied to the backing cache of Document.data
. If Document.followcache
is true the document doc
has also accepted the change.
- module:Party.
IDocument. Event
- Source
value
Document value Event - This event is triggered after a change has been applied to the backing cache of Document.data
. Only fired when Document.followcache
is true.
- Document
- Source