Instance document formats

A JSON instance document for a MongoDB collection can represent a single document in a collection or many documents in a collection. The MongoDB adapter supports both formats.

Single document format

The format of an instance document (.json file) that represents a single document is similar to the following:
{
    JSON-document-data
}
For example:
{
    Customer : Company X,
    Location : Europe 
 }

Multiple document format

It's common to have more than one document in a MongoDB collection. In this case, an instance document (.json file) includes more than one document in a JSON array. Each document in a JSON array is saved as separate document in the MongoDB collection. The format of the instance document is similar to the following:
[
    {
       JSON-document-data
    },
    {
       JSON-document-data
    }
]
For example:
[
    {
       Customer : Company X,
       Location : Europe
    },
    {
       Customer : Company Y,
       Location : North America
    }
]

Managing document formats

When the schema of an input card represents single instance document, the -SDF command is required. The -SDF command indicates that the adapter is to send a non-array style, single JSON instance document to the map, even if the adapter fetches multiple documents. A single-document schema cannot validate an array-style, multiple-document instance.

When the schema of an output card represents single instance document, the -SDF command is required to ensure the adapter treats the instance as single document; otherwise, adapter errors occur when inserting documents into the MongoDB collection.

When you specify the -SDF command, the MongoDB adapter cannot transmit documents in array-style, multiple-document format.

By default, the MongoDB adapter processes instance documents as multiple-document arrays (multiple-document format). There is no corresponding command option.

When the schema of an input card represents an array-style (multiple-document) instance document, the Native JSON parser can successfully process documents that are in either single-document format or multiple-document format. When the schema of an output document represents an array-style instance document, the adapter can insert only documents that are in multiple-document format into a MongoDB collection.