Skip to content

Finding documents (persistent.findDocumentsV1)

You can use persistent.findDocumentsV1 to find documents based on a particular document definition. Unlike persistent.findDocuments, this method does not throw an error when the query object contains undefined values or is entirely undefined.

Syntax

persistent.findDocumentsV1(ddName, queryObject, queryOptions);

Parameters

Parameter Type Required Description
ddName String Yes The name of the document definition. If the value is null, BizzStream will use the name of the document from which the script was started.
queryObject object No The object with which you can specify the search criteria. This object has to be made in the Mongo query format
queryOptions Object No The options that can be used in the Mongo query

Query options

Query Parameter Type Description
sort number Used for the soring order (default: natural order). This is an object that contains the fields and their sorting order. The value -1 represents a descending sorting order while the value 1 represents an ascending sorting order
skip number Number of results to skip at the beginning.
fields number Dictionary of fields to return or exclude. This is an object that contains the fields and an indication of whether the field is included (value 1) or excluded (value -1)
limit number Maximum number of results to return.

Return value

An array containing the documents. If no documents can be found, a null value.

Examples

The following method allows you to search for documents of the type project for which the projectNr field is equal to 12345.

persistent.findDocuments('project', {"projectNr":"12345"});
console.log('Give me the documents with projectnumber 12345', projectNumber)