New N/dataStore Module: Document-Oriented Storage Without Custom Records
SuiteScript 2.1 gains the N/dataStore module, a document-oriented JSON store with collection-based CRUD, async cursors, and SuiteApp-scoped isolation — no custom records required.
What changed
NetSuite introduced the N/dataStore module for SuiteScript 2.1 server scripts. It provides a document-oriented storage layer that persists arbitrary JSON objects (called documents) without requiring you to define custom record types, fields, or sublists. Think of it as a lightweight NoSQL-style store embedded in NetSuite.
Core concepts
- Data Store — a named container. Obtained via
dataStore.getDatastore(id). Adefaultdata store is always available. - Collection — a named grouping of documents inside a data store. Obtained via
Datastore.getCollection(id), or the shortcutdataStore.getCollection(id)which implicitly targets thedefaultdata store. - Document — a JSON object with a system-generated
_idplus your custom properties.
API surface
All Collection methods are async and return Promises. You must use await or .then() to consume results. The key return types are:
InsertOneResult/InsertManyResult— generated_id, document metadata, and insertion counts.FindOneResult/FindResult— matching document plusDocumentMetadata(byte size, version).Cursor— async iterator over matching documents.UpdateResult— count of documents updated.DeleteResult— count of documents deleted (viadeleteOneordeleteMany).
Storage scoping
The executing script's context determines data isolation:
- Account scope — all non-SuiteApp scripts in the account share the same data stores and collections when using the same identifiers.
- SuiteApp scope — each SuiteApp's scripts are isolated from account-scope data and from every other SuiteApp.
Restrictions
- Server scripts only — not available in client scripts, user-event beforeLoad context on the client side, or Suitelets rendered as forms.
- No sensitive data — Oracle explicitly warns against storing PII, credentials, or other sensitive information. There is no mention of encryption at rest or field-level access controls.
- SuiteBundler is not supported — scripts using
N/dataStorecannot be installed via SuiteBundler. A script deployed through SDF will fail if it is later bundled. You must use Account Customization Projects (ACP) or Copy to Account for migration.
The release notes do not specify governance costs, document size limits, collection count caps, or query operators for find/delete/update. These details should be verified in the full API reference or through empirical testing before building production workflows on this module.
What to do
- Evaluate use cases. This module is a fit for script-local caches, staging areas, transient processing state, or configuration blobs where a full custom record is overkill. It is not a replacement for custom records when you need saved-search support, role-based field access, workflow triggers, or SuiteAnalytics visibility.
- Audit your deployment method. If you currently distribute scripts via SuiteBundler, you cannot adopt
N/dataStoreuntil you migrate those scripts to SDF Account Customization Projects. Plan that migration first. - Confirm governance and limits. Oracle's documentation does not yet clarify governance unit consumption per operation, maximum document size, or per-collection caps. Run controlled tests in a sandbox with
N/runtime.getCurrentScript().getRemainingUsage()before and after calls to measure cost. - Design for scope isolation. Decide up front whether your scripts should share data at the account level or be isolated per SuiteApp. If you later refactor a standalone script into a SuiteApp (or vice versa), the data will be in a different scope and will not carry over automatically.
- Handle async correctly. All collection methods return Promises. Wrap calls in
asyncentry points and useawait. If you are in a Map/Reduce script, ensure youawaitin each stage — returning a pending Promise without awaiting it will silently drop the operation. - Do not store sensitive data. No encryption or access-control features are documented. Use
N/cryptoor external vaults if you need to persist anything confidential.
Source: Oracle NetSuite Release Notes