Document

new Document(options)

Document

Parameters:
  • options optional
    • Type: Object
      • key optional
        • Type: string or Key
        • optional may be set later

      • data optional
        • Type: mixed
      • cas optional
        • Type: CAS
        • optional

      • isNewRecord optional
        • Type: boolean
        • default=true

Throws:
getCAS()CAS or null
Returns: CAS or null
getData(property)mixed
Parameters:
  • property optional
    • Type: string
Returns: mixed
getGeneratedKey()Promise<Key>
Returns: Promise<Key>
getKey()Key or string or null
Returns: Key or string or null
getSerializedData()Promise<{mixed}>
Returns: Promise<{mixed}>
getStorageAdapter()StorageAdapter or null
Returns: StorageAdapter or null
hasCAS()boolean
Returns: boolean
insert(options)Promise<Document>

Inserts new document. This is an atomic operation which always operates on single document only.

Parameters:
  • options
    • Type: Object
    • See StorageAdapter.insert for available options

Throws:
  • StorageError

Returns: Promise<Document>
refresh()Promise<Instance>
Returns: Promise<Instance>
remove(options)Promise<Object>

Removes the document identified by its key. This is an atomic operation which always operates on single document only.

Parameters:
  • options
    • Type: Object
    • See StorageAdapter.remove for available options

Returns: Promise<Object>
replace(options)Promise<Document>

Replaces (updates) the document identified by its key. This is an atomic operation which always operates on single document only.

Parameters:
  • options
    • Type: Object
    • See StorageAdapter.replace for available options

Throws:
  • StorageError

Returns: Promise<Document>
setCAS(cas)undefined
Parameters:
  • cas
    • Type: CAS
Returns: undefined
setData(property, data)Document
Parameters:
  • property optional
    • Type: string
  • data
    • Type: mixed
Returns: Document
setKey()undefined
Throws:
  • DocumentError

Returns: undefined
toString()string
Returns: string
touch(expiry, options)Promise<Document>

Touches the document identified by its key. This is an atomic operation which always operates on single document only.

Parameters:
  • expiry
    • Type: integer
    • time in seconds

Throws:
  • StorageError

Returns: Promise<Document>
comments powered by Disqus