Collection.insertOne(document)
The content in this help topic pertains to SuiteScript 2.1.
|
Method Description |
Inserts one document and generates its The generated |
|
Returns |
Promise Object. Resolves to dataStore.InsertOneResult. |
|
Supported Script Types |
Server scripts |
|
Governance |
2 units |
|
Module |
|
|
Parent Object |
|
|
Sibling Object Members |
|
|
Since |
2026.2 |
Parameters
|
Parameter |
Type |
Required / Optional |
Description |
Since |
|---|---|---|---|---|
|
|
Object |
required |
The document to insert. An empty object is valid. Don't include a top-level For supported values and the stored document format, see dataStore.Document. |
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. |
|
|
Property names must be nonempty. They can't contain dots, start with |
An inserted document contains an unsupported property name, including within nested objects or arrays. |
|
|
The generated update path exceeds 4,000 bytes after UTF-8 encoding. Shorten the property name. |
A property name produces an internal path that exceeds the 4,000-byte limit. |
|
|
Document numbers must be 0 or have an absolute value of at least 1e-130 and less than 1e126. |
A nonzero number in a document has an absolute value below |
|
|
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. |
|
|
A document must be a non-null object. |
An inserted document is null. |
|
|
Document IDs are generated automatically. Omit the top-level |
The document includes a top-level |
|
|
Document numbers must be finite, including numbers in nested objects and arrays. |
A document contains a nonfinite number. |
|
|
Data Store inputs must not contain circular references. |
A document, query, or update input contains a circular reference. |
|
|
The JSON document body exceeds the 10 MB limit when encoded as UTF-8. Reduce the document size. |
An inserted or resulting updated document body exceeds 10 MB. |
|
|
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. |
|
|
A document with the same identifier already exists. |
Insertion encounters a duplicate generated document identifier and rollback is confirmed. |
|
|
The operation may have been committed. Don't retry automatically. |
The operation's outcome can't be determined, and its changes may have been saved. |
|
|
The operation was committed, but its result couldn't be returned. Don't retry. |
The changes were saved, but the operation couldn't return its result. |
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 result = await collection.insertOne({
process: 'import', status: 'pending', completed: 0
});
const documentId = result.insertedId;
...
// Add additional code