Collection.insertMany(documents)
The content in this help topic pertains to SuiteScript 2.1.
|
Method Description |
Inserts multiple documents and generates an Insertion results follow the input order. The combined normalized document bodies must not exceed 10 MB, excluding generated IDs. An empty array is accepted and inserts no documents. |
|
Returns |
Promise Object. Resolves to dataStore.InsertManyResult. |
|
Supported Script Types |
Server scripts |
|
Governance |
10 units |
|
Module |
|
|
Parent Object |
|
|
Sibling Object Members |
|
|
Since |
2026.2 |
Parameters
|
Parameter |
Type |
Required / Optional |
Description |
Since |
|---|---|---|---|---|
|
|
Object[] |
required |
The array of documents to insert. Each document can be an empty object. 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 combined JSON document bodies in this insert batch exceed 10 MB when encoded as UTF-8. Split the documents into smaller batches. |
The combined normalized document bodies in an insert batch exceed 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.insertMany([
{ process: 'importA', status: 'pending', completed: 0 },
{ process: 'importB', status: 'pending', completed: 0 }
]);
const firstId = result.inserted[0].insertedId;
...
// Add additional code