dataStore.Document

Note:

The content in this help topic pertains to SuiteScript 2.1.

Object Description

A JSON object representing a stored document.

Each stored document includes a generated _id property. Access stored documents as follows:

When constructing documents to insert, consider the following:

  • Document identifiers. Insert operations generate the _id property. Don't include a top-level _id in the document you pass for insertion. For identifier details, see Document._id.

  • Property names. Use supported property names when constructing documents to insert. For the requirements, see Data Store Query Rules and Update Object Rules.

  • Property-name length. When inserting documents, the internal path generated from each property name must not exceed 4,000 bytes after UTF-8 encoding. This limit includes escaping and required path syntax. It applies separately to each property name, including names in nested objects and arrays.

  • Property values. Properties can contain strings, finite numbers, booleans, null, nested objects, and arrays.

  • Numeric values. Numeric values must be 0, or have an absolute value of at least 1e-130 and less than 1e126. This range also applies to numbers in nested objects and arrays.

  • Dates. JavaScript Date values are stored as UTC strings in ISO 8601 format. Read operations return these strings instead of Date objects. Convert a returned string to a Date object to perform date operations. To format dates according to NetSuite preferences, see format.format(options).

  • Functions. Documents can't contain JavaScript functions as property values or array elements, including within nested objects and arrays. Functions supplied as values aren't executed.

The normalized JSON document body, including property names and values, must not exceed 10 MB (10,485,760 bytes). This limit excludes the generated _id. For the measured body size, see DocumentMetadata.byteLength.

Supported Script Types

Server scripts

Module

N/dataStore Module

Methods and Properties

Document Object Members

Since

2026.2

Document Object Members

Member Type

Name

Return Type / Value Type

Supported Script Types

Description

Property

Document._id

string

Server scripts

The system-generated document identifier.

Syntax

Important:

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 collection = dataStore.getCollection('checkpoints');
const result = await collection.findOne({ status: 'pending' });

if (result.document !== null) {
    const document = result.document;
    const documentId = document._id;
    const status = document.status;
}

...
// Add additional code 

          

General Notices