Collection.find(query)
The content in this help topic pertains to SuiteScript 2.1.
|
Method Description |
Finds all documents that match the query. Results are ordered by |
|
Returns |
Promise Object. Resolves to dataStore.Cursor. |
|
Supported Script Types |
Server scripts |
|
Governance |
10 units for the initial retrieval. |
|
Module |
|
|
Parent Object |
|
|
Sibling Object Members |
|
|
Since |
2026.2 |
Parameters
|
Parameter |
Type |
Required / Optional |
Description |
Since |
|---|---|---|---|---|
|
|
Object |
required |
The conditions used to match documents in the collection. An empty object matches all documents. For the supported structure and operators, see Data Store Query Object. |
2026.2 |
Errors
|
Error Code |
Error Message |
Thrown If |
|---|---|---|
|
|
The |
Data Store is disabled for the account. |
|
|
The |
The executing script belongs to a bundle. |
|
|
Functions can't be used as values in documents, queries, or updates. Replace each function with a supported value. |
A supplied document, query, or update contains a JavaScript function as a value, including within nested objects or arrays. |
|
|
Data Store inputs must not contain circular references. |
The query contains a circular reference. |
|
|
The query expression exceeds the limit of 300 operators. Simplify the query. |
The query expression contains more than 300 operators, including implicit comparisons and logical connectors. |
|
|
Use no more than 100 values with each |
An |
|
|
Use |
A query uses an unsupported logical operator. |
|
|
Field operator objects must contain at least one operator. |
A field-operator object is empty. |
|
|
Use a number or string with ordering comparison operators. |
An ordering comparison uses an incompatible operand. |
|
|
The field operator or direct object comparison isn't supported. Use a supported operator or compare individual object properties. |
A query uses an unsupported field operator or directly compares an object. |
|
|
|
The |
|
|
Nested |
The query nests |
|
|
Field paths are limited to 32 segments and 256 UTF-8 bytes. |
A complete query path exceeds either limit. |
|
|
Use nonempty object property names in field paths. Array indexes and JSONPath syntax aren't supported. |
A field path contains unsupported syntax. |
|
|
Query string literals are limited to 4,000 UTF-8 bytes. |
A string operand exceeds the byte limit. |
|
|
Query numbers must be finite. |
A numeric query operand is nonfinite. |
|
|
Query numbers must be 0 or have an absolute value of at least 1e-130 and less than 1e126. |
A nonzero numeric query value has an absolute value below |
|
|
Use JSON scalar values for comparisons. Objects and arrays can't be compared directly. |
A direct comparison uses a nonscalar value. |
|
|
A query predicate must be a JSON object. |
A query predicate is not an object. |
|
|
Query object keys must be strings. |
A query object has a nonstring key. |
|
|
Logical and membership operators require nonempty arrays. |
A logical or membership operand is empty or is not an array. |
|
|
The operation requires too many bound parameters. Simplify the query or reduce the batch size. |
The operation requires more than 32,000 bound parameters, including internal parameters. |
Syntax
The following code sample shows the syntax for this member. It isn't a functional example. For a complete script example, see N/dataStore Module Script Samples.
// Add additional code
...
const cursor = await collection.find({ status: 'pending' });
for await (const result of cursor) {
log.debug({ title: result.document._id, details: result.document });
}
...
// Add additional code