+
+
+
+
+
+
Constructor
+
+
+
+
new Document(transport, path, originalJson)
+
+
+
+
+
+
+
+ Document constructor
+
+
+
+
+
+
+
+
+
+
+
Parameters:
+
+
+
+
+
+
+ Name |
+
+
+ Type |
+
+
+
+
+
+ Description |
+
+
+
+
+
+
+
+
+ transport |
+
+
+
+
+
+Transport
+
+
+
+ |
+
+
+
+
+
+ transport layer |
+
+
+
+
+
+
+ path |
+
+
+
+
+
+String
+
+
+
+ |
+
+
+
+
+
+ Document rest uri |
+
+
+
+
+
+
+ originalJson |
+
+
+
+
+
+Object
+
+
+
+ |
+
+
+
+
+
+ document data as plain json |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ - Source:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Members
+
+
+
+id
+
+
+
+
+
+ Get resource identity
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ - Source:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+version
+
+
+
+
+
+ getter for Document version
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ - Source:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Methods
+
+
+
+
+
+
+
+ _update(data) → {Promise}
+
+
+
+
+
+
+
+ Update document
+
+
+
+
+
+
+
+
+
+
+ Parameters:
+
+
+
+
+
+
+ Name |
+
+
+ Type |
+
+
+
+
+
+ Description |
+
+
+
+
+
+
+
+
+ data |
+
+
+
+
+
+Object
+
+
+
+ |
+
+
+
+
+
+ data to be updated |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ - Source:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Returns:
+
+
+
+ resolves when opration success
+
+
+
+
+
+ -
+ Type
+
+ -
+
+Promise
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ delete() → {Promise}
+
+
+
+
+
+
+
+ delete this document
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ - Source:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Returns:
+
+
+
+ Resolves when operation success
+
+
+
+
+
+ -
+ Type
+
+ -
+
+Promise
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ get(key, defaultValue) → {String|Object}
+
+
+
+
+
+
+
+ Get resource value by Key.
+
+
+
+
+
+
+
+
+
+
+ Parameters:
+
+
+
+
+
+
+ Name |
+
+
+ Type |
+
+
+
+
+
+ Description |
+
+
+
+
+
+
+
+
+ key |
+
+
+
+
+
+String
+
+
+
+ |
+
+
+
+
+
+ key can be nested as well like "a.b.c" |
+
+
+
+
+
+
+ defaultValue |
+
+
+
+
+
+String
+
+
+
+ |
+
+
+
+
+
+ optional default value |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ - Source:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Returns:
+
+
+
+ value for the key or undefined if not found
+
+
+
+
+
+ -
+ Type
+
+ -
+
+String
+|
+
+Object
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ getChanges() → {object}
+
+
+
+
+
+
+
+ get changes as json object
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ - Source:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Returns:
+
+
+
+ returns changes as plain json
+
+
+
+
+
+ -
+ Type
+
+ -
+
+object
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ getOrSet(key, value) → {Resource|value}
+
+
+
+
+
+
+
+ get or set value to resource.
+
+
+
+
+
+
+
+
+
+
+ Parameters:
+
+
+
+
+
+
+ Name |
+
+
+ Type |
+
+
+
+
+
+ Description |
+
+
+
+
+
+
+
+
+ key |
+
+
+
+
+
+string
+
+
+
+ |
+
+
+
+
+
+ key to be get/set |
+
+
+
+
+
+
+ value |
+
+
+
+
+
+*
+
+
+
+ |
+
+
+
+
+
+ undefined (default) to get value by key, null to remove key, others to set value |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ - Source:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Returns:
+
+
+
+ value or whole object when set
+
+
+
+
+
+ -
+ Type
+
+ -
+
+Resource
+|
+
+value
+
+
+
+
+
+
+
+
+
+
+ Example
+
+ // returns Document
+doc.set('key1', 'myvalue')
+ .set('key2', 'val')
+
+
+
+
+
+
+
+
+
+ isDirty() → {boolean}
+
+
+
+
+
+
+
+ returns true when there is changes made by client
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ - Source:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Returns:
+
+
+
+ check if document is "dirty" - has local changes
+
+
+
+
+
+ -
+ Type
+
+ -
+
+boolean
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ overwrite(values) → {Document}
+
+
+
+
+
+
+
+ Overwrite document with new allowedValue
+
+
+
+
+
+
+
+
+
+
+ Parameters:
+
+
+
+
+
+
+ Name |
+
+
+ Type |
+
+
+
+
+
+ Description |
+
+
+
+
+
+
+
+
+ values |
+
+
+
+
+
+Object
+
+
+
+ |
+
+
+
+
+
+ new data |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ - Source:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Returns:
+
+
+
+ document object
+
+
+
+
+
+ -
+ Type
+
+ -
+
+Document
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ refresh() → {Promise.<Document>}
+
+
+
+
+
+
+
+ reload document information from backend.
+This also revert all client modified data back that is not saved!
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ - Source:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Returns:
+
+
+
+ resolves Document
+
+
+
+
+
+ -
+ Type
+
+ -
+
+Promise.<Document>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ save(retryCount) → {Promise}
+
+
+
+
+
+
+
+ Save document. If conflicts happen try merge and save again.
+if there is no retries left or some server side changes causes conflict
+promise is rejected and reason property tells was it no retries left or merge conflicts.
+
+
+
+
+
+
+
+
+
+
+ Parameters:
+
+
+
+
+
+
+ Name |
+
+
+ Type |
+
+
+
+
+ Default |
+
+
+ Description |
+
+
+
+
+
+
+
+
+ retryCount |
+
+
+
+
+
+Number
+
+
+
+ |
+
+
+
+
+
+
+ 2
+
+ |
+
+
+ count how many times we try to save. |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ - Source:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Returns:
+
+
+
+ Resolves Document itself when save success
+
+
+
+
+
+ -
+ Type
+
+ -
+
+Promise
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ set(key, value) → {Document}
+
+
+
+
+
+
+
+ Set value for a key
+
+
+
+
+
+
+
+
+
+
+ Parameters:
+
+
+
+
+
+
+ Name |
+
+
+ Type |
+
+
+
+
+
+ Description |
+
+
+
+
+
+
+
+
+ key |
+
+
+
+
+
+String
+
+
+
+ |
+
+
+
+
+
+ key for update |
+
+
+
+
+
+
+ value |
+
+
+
+
+
+*
+
+
+
+ |
+
+
+
+
+
+ value for update |
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ - Source:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Returns:
+
+
+
+ returns this
+
+
+
+
+
+ -
+ Type
+
+ -
+
+Document
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ toJson() → {object}
+
+
+
+
+
+
+
+ Get resource data as plain json object
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ - Source:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Returns:
+
+
+
+ returns document as plain json
+
+
+
+
+
+ -
+ Type
+
+ -
+
+object
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+