Party. IDocument

new IDocument(options)

Represents a document with caching and local+remote change notifications

Parameters:
NameTypeDescription
optionsobject
Properties
NameTypeDescription
partyDataParty
idstring
typestring
dataobject
followcacheboolean

Extends

  • EventEmitter

Members

(static) cleanData :object

document data with no library added fields

Type:
  • object

(static) data :object

entire document

Type:
  • object

(static) Document :IDocument

Type:
  • IDocument

(static) hash :object

hash of document.data using sha256

Type:
  • object

(static) id :string

Document mongo-id

Type:
  • string

(static) idObj :IdObj

Document id object

Type:

(static) idString :sting

Document id string in format <type>:<mongo-id>

Type:
  • sting

(static) revision :string

Document revision string

Type:
  • string

(static) type :string

Document type string

Type:
  • string

Methods

(async, static) create(party, document)

Parameters:
NameTypeDescription
partymoddule:Party.IParty
document*
Returns:

(static) getData()

(async, static) mergeData(input) → {object}

Parameters:
NameTypeDescription
inputobject
Returns:
Type: 
object

(async, static) pull(flushcache)

Parameters:
NameTypeDescription
flushcacheboolean

Update local cache as well

(async, static) remove()

(async, static) save()

(async, static) setData(input) → {object}

Parameters:
NameTypeDescription
inputobject
Returns:
Type: 
object

(static) unwatch(cbopt)

Stop watching for remote document changes

Parameters:
NameTypeAttributesDescription
cbfunction<optional>

Optional Change event callback function

(async, static) watch(autopull, flushcache, cbopt)

Parameters:
NameTypeAttributesDescription
autopullboolean
flushcacheboolean
cbfunction<optional>

Optional Change event callback function

(static) watchField(field, valueopt, cb)

Watch a field for changes. If value is supplied watches for field and value to match.

Parameters:
NameTypeAttributesDescription
fieldstring

Field path to watch for changes

value*<optional>

Match value

cbfunction

Callback function

Events

change

Document change Event - This is event is triggered when a document has been modified on the remote service

Type:
  • object

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.

Type:
  • module:Party.IDocument.Event

field

Field change event. This is emitted as field.[FIELD_PATH]

Type:
  • object
Properties
NameTypeDescription
doc

The changed document

field

The changed FIELDPATH

old

The old field value

new

The new field value

expected

The expected field value

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.

Type:
  • module:Party.IDocument.Event

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.

Type:
  • module:Party.IDocument.Event

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.

Type:
  • Document