Namespace: documents
documents
Provides functions to write, read, query,
or perform other operations on documents in the database. For
operations that modify the database, the client must have been
created for a user with the rest-writer role. For operations that
read or query the database, the user need only have the rest-reader
role.
Methods
-
-
advanceLsqt(temporalCollection, lag) → {ResultProvider}
-
Advances the LSQT (Last Stable Query Time) of a temporal collection.
Parameters:
Name Type Argument Description temporalCollectionstring The name of the temporal collection for which to advance the LSQT. lagstring <optional>
The lag (in seconds (???)) to subtract from the maximum system start time in the temporal collection to determine the LSQT. - Since:
-
- 2.1.1
Returns:
an object whose result() function takes an object with the new LSQT as an 'lsqt' property.- Type
- ResultProvider
-
-
createWriteStream(uri, collections, permissions, properties, quality, metadataValues, versionId, txid, transform) → {WritableStream}
-
Writes a large document (typically a binary) in incremental chunks with a stream; takes a documents.DocumentDescriptor object with the following properties (but not a content property).
Parameters:
Name Type Argument Description uristring the identifier for the document to write to the database collectionsArray.<string> <optional>
the collections to which the document should belong permissionsArray.<object> <optional>
the permissions controlling which users can read or write the document propertiesArray.<object> <optional>
additional properties of the document qualitynumber <optional>
a weight to increase or decrease the rank of the document metadataValuesArray.<object> <optional>
the metadata values of the document versionIdnumber <optional>
an identifier for the currently stored version of the document (when enforcing optimistic locking) txidstring | transactions.Transaction <optional>
a string transaction id or Transaction object identifying an open multi-statement transaction transformstring | Array.<mixed> <optional>
the name of a transform extension to apply to each document or an array with the name of the transform extension and an object of parameter values; the transform must have been installed using the transforms#write function. - Since:
-
- 1.0
Returns:
a stream for writing the database document; the stream object also has a result() function that takes a documents#writeResult success callback.- Type
- WritableStream
-
-
patch(uri, operations, categories, temporalCollection, temporalDocument, sourceDocument, txid, versionId) → {ResultProvider}
-
Applies changes to a document; takes a configuration object with the following named parameters or, as a shortcut, a uri string and one or more patch operations produced by a patchBuilder.
Parameters:
Name Type Argument Description uristring the uri operationspatchOperation | Array.<patchOperation> delete, insert, or replace operations produced by a patchBuilder to apply to the document. categoriesdocuments.categories | Array.<documents.categories> <optional>
the categories of information modified by the patch (typically 'content') temporalCollectionstring <optional>
the name of the temporal collection; use only when patching temporal documents temporalDocumentstring <optional>
the collection URI for the temporal document to be patched; use only when patching temporal documents sourceDocumentstring <optional>
the source collection URI for patching the temporal document; use only when writing temporal documents txidstring | transactions.Transaction <optional>
a string transaction id or Transaction object identifying an open multi-statement transaction to patch the document as part of a larger multi-statement transaction versionIdnumber <optional>
an identifier for the currently stored version of the document (when enforcing optimistic locking) - Since:
-
- 1.0
Returns:
an object whose result() function takes a documents#patchResult success callback.- Type
- ResultProvider
-
-
probe(uri, txid) → {ResultProvider}
-
Probes whether a document exists; takes a configuration object with the following named parameters or, as a shortcut, a uri string.
Parameters:
Name Type Argument Description uristring the uri for the database document txidstring | transactions.Transaction <optional>
a string transaction id or Transaction object identifying an open multi-statement transaction - Since:
-
- 1.0
Returns:
an object whose result() function takes a documents#probeResult success callback.- Type
- ResultProvider
-
-
protect(uri, temporalCollection, duration, expireTime, level, archivePath) → {ResultProvider}
-
Protects a temporal document from temporal operations for a period of time.
Parameters:
Name Type Argument Description uristring the uri for the temporal document to protect temporalCollectionstring the temporal collection for the document durationstring <optional>
a protection duration; either a duration or an expire time must be provided expireTimestring <optional>
an expiration time; either an expiration time or a duration must be provided levelstring <optional>
a protection level of 'noWipe'|'noDelete'|'noUpdate' (default is 'noDelete') archivePathstring <optional>
an archive path - Since:
-
- 2.0.1
Returns:
an object whose result() function takes a documents#protectResult success callback.- Type
- ResultProvider
-
-
query(query, timestamp) → {ResultProvider}
-
Executes a query built by a queryBuilder to match one or more documents.
Parameters:
Name Type Argument Description queryobject a query built by a queryBuilder or a documents.CombinedQueryDefinition timestampDatabaseClient.Timestamp <optional>
a Timestamp object for point-in-time operations. - Since:
-
- 1.0
Returns:
an object whose result() function takes a documents#resultList success callback.- Type
- ResultProvider
-
-
read(uris, categories, txid, transform, range, timestamp) → {ResultProvider}
-
Reads one or more documents; takes a configuration object with the following named parameters or, as a shortcut, one or more uri strings or an array of uri strings.
Parameters:
Name Type Argument Description urisstring | Array.<string> the uri string or an array of uri strings for the database documents categoriesdocuments.categories | Array.<documents.categories> <optional>
the categories of information to retrieve for the documents txidstring | transactions.Transaction <optional>
a string transaction id or Transaction object identifying an open multi-statement transaction transformstring | Array.<mixed> <optional>
the name of a transform extension to apply to each document or an array with the name of the transform extension and an object of parameter values; the transform must have been installed using the transforms#write function. rangeArray.<number> <optional>
the range of bytes to extract from a binary document; the range is specified with a zero-based start byte and the position after the end byte as in Array.slice() timestampDatabaseClient.Timestamp <optional>
a Timestamp object for point-in-time operations. - Since:
-
- 1.0
Returns:
an object whose result() function takes a documents#resultList success callback.- Type
- ResultProvider
-
-
remove(uris, txid, temporalCollection, systemTime) → {ResultProvider}
-
Removes one or more database documents; takes a configuration object with the following named parameters or, as a shortcut, one or more uri strings or an array of uri strings.
Parameters:
Name Type Argument Description urisstring | Array.<string> the uri string or an array of uri strings identifying the database documents txidstring | transactions.Transaction <optional>
a string transaction id or Transaction object identifying an open multi-statement transaction temporalCollectionstring <optional>
the name of the temporal collection; use only when deleting a document created as a temporal document; sets the system end time to record when the document was no longer active systemTimestring | Date <optional>
a datetime to use as the system end time instead of the current time of the database server; can only be supplied if the temporalCollection parameter is also supplied - Since:
-
- 1.0
Returns:
an object whose result() function takes a documents#removeResult success callback.- Type
- ResultProvider
-
-
removeAll(collection, directory) → {ResultProvider}
-
Removes all documents in a collection, directory, or database; takes a configuration object with the following named parameters or no parameters to delete all documents. The user must have the rest-admin role to to delete all documents and the rest-writer role otherwise.
Parameters:
Name Type Argument Description collectionstring <optional>
the collection whose documents should be deleted directorystring <optional>
a directory whose documents should be deleted - Since:
-
- 1.0
Returns:
an object with a result() function taking success and failure callbacks.- Type
- ResultProvider
-
-
suggest(partial, query, bindings, limit) → {ResultProvider}
-
For a partial textual value intended for a string search, looks up completions that match documents in the database. The textual value may be prefixed with the constraint name for a string search binding or facet. The textual value may also be an unqualified word or phrase for the default binding. You may pass a configuration object with the following named parameters or, as a shortcut, the partial textual search, the query, and optionally bindings.
Parameters:
Name Type Argument Description partialstring the partial search string to complete queryobject a query built by a queryBuilder or a documents.CombinedQueryDefinition that defines bindings in the where and calculate clause and that qualifies the documents supplying the completions for the partial search string bindingsqueryBuilder.SuggestBindings <optional>
bindings returned by the queryBuilder#suggestBindings function that override the query bindings to retrieve completions from a different index limitnumber <optional>
the number of completions to return - Since:
-
- 1.0
Returns:
an object whose result() function takes a success callback that receives an array with the candidate completion strings.- Type
- ResultProvider
-
-
wipe(uri, temporalCollection) → {ResultProvider}
-
Deletes all versions of a temporal document.
Parameters:
Name Type Description uristring the uri for the temporal document to wipe temporalCollectionstring the name of the temporal collection - Since:
-
- 2.0.1
Returns:
an object whose result() function takes a documents#wipeResult success callback.- Type
- ResultProvider
-
-
write(documents, categories, txid, transform, forestName, temporalCollection, systemTime) → {ResultProvider}
-
Writes one or more documents; takes a configuration object with the following named parameters or, as a shortcut, a document descriptor.
Parameters:
Name Type Argument Description documentsDocumentDescriptor | Array.<DocumentDescriptor> one descriptor or an array of document descriptors to write categoriesdocuments.categories | Array.<documents.categories> <optional>
the categories of information to write for the documents txidstring | transactions.Transaction <optional>
a string transaction id or Transaction object identifying an open multi-statement transaction transformstring | Array.<mixed> <optional>
the name of a transform extension to apply to each document or an array with the name of the transform extension and an object of parameter values; the transform must have been installed using the transforms#write function. forestNamestring <optional>
the name of a forest in which to write the documents. temporalCollectionstring <optional>
the name of the temporal collection; use only when writing temporal documents that have the JSON properties or XML elements specifying the valid and system start and end times as defined by the valid and system axis for the temporal collection systemTimestring | Date <optional>
a datetime to use as the system start time instead of the current time of the database server; can only be supplied if the temporalCollection parameter is also supplied - Since:
-
- 1.0
Returns:
an object whose result() function takes a documents#writeResult success callback.- Type
- ResultProvider
Type Definitions
-
-
categories
-
Categories of information to read or write for documents. The possible values of the enumeration are content|collections|metadataValues|permissions|properties|quality|metadata|none where metadata is an alias for all of the categories other than content.
Type:
- enum
- Since:
-
- 1.0
-
-
CombinedQueryDefinition
-
Defines a query in the structure accepted by the REST API.
Type:
- object
-
Properties:
-
Name Type Argument Description searchobject a combined query, which can have properties for a structured query, a string query, and query options categoriesdocuments.categories | Array.<documents.categories> <optional>
the categories of information to retrieve for the result documents optionsNamestring <optional>
query options installed on the REST server to merge with any query options provided in the combined query; provided options take precedence over installed options pageStartnumber <optional>
the position of the first document in the returned page of result documents (also known as the result slice) pageLengthnumber <optional>
the number of documents in the returned page of result documents viewstring <optional>
a value from the enumeration all|facets|metadata|none|results|uris controlling whether to generate some or all of a search response summarizing the search response in addition to the result documents; the default is 'none' to return only the result documents
-
- Since:
-
- 1.0
-
-
DocumentDescriptor
-
Provides a description of a document to write to the server, after reading from the server, or for another document operation. The descriptor may have more or fewer properties depending on the operation.
Type:
- object
-
Properties:
-
Name Type Argument Description uristring the identifier for the document in the database contentobject | string | Buffer | ReadableStream <optional>
the content of the document; when writing a ReadableStream for the content, first pause the stream collectionsArray.<string> <optional>
the collections to which the document belongs permissionsArray.<object> <optional>
the permissions controlling which users can read or write the document propertiesArray.<object> <optional>
additional properties of the document qualitynumber <optional>
a weight to increase or decrease the rank of the document metadataValuesArray.<object> <optional>
the metadata values of the document versionIdnumber <optional>
an identifier for the currently stored version of the document temporalDocumentstring <optional>
the collection URI for a temporal document; use only when writing a document to a temporal collection
-
- Since:
-
- 1.0
-
-
patchResult(document)
-
A success callback for ResultProvider that receives the result from the documents#patch function.
Parameters:
Name Type Description documentobject a sparse documents.DocumentDescriptor object providing the uri of the patched document. - Since:
-
- 1.0
-
-
probeResult(document)
-
A success callback for ResultProvider that receives the result from the documents#probe.
Parameters:
Name Type Description documentdocuments.DocumentDescriptor a sparse document descriptor with an exists property that identifies whether the document exists - Since:
-
- 1.0
-
-
protectResult(document)
-
A success callback for ResultProvider that receives the result from the documents#protect.
Parameters:
Name Type Description documentdocuments.DocumentDescriptor a sparse document descriptor for the protected document - Since:
-
- 2.0.1
-
-
removeResult(document)
-
A success callback for ResultProvider that receives the result from the documents#remove.
Parameters:
Name Type Description documentdocuments.DocumentDescriptor a sparse document descriptor for the removed document - Since:
-
- 1.0
-
-
resultList(documents)
-
A success callback for ResultProvider that receives the result from the documents#read.
Parameters:
Name Type Description documentsArray.<documents.DocumentDescriptor> an array of documents.DocumentDescriptor objects with the requested metadata and/or content for the documents - Since:
-
- 1.0
-
-
wipeResult(document)
-
A success callback for ResultProvider that receives the result from the documents#wipe.
Parameters:
Name Type Description documentdocuments.DocumentDescriptor a sparse document descriptor for the wipe command - Since:
-
- 2.0.1
-
-
writeResult(response)
-
A success callback for ResultProvider that receives the result from the documents#write or the documents#createWriteStream functions.
Parameters:
Name Type Description responseobject a response with a documents property providing a sparse array of array of documents.DocumentDescriptor objects providing the uris of the written documents. - Since:
-
- 1.0