Generating Schema
To effectively validate and process MongoDB documents within Link using the MongoDB
adapter, it is essential to create a JSON schema that accurately reflects the structure
of your MongoDB documents. For Generating Schema, follow these steps:
- Open Link project in Design Server UI workspace.
- Navigate to Schema View: In the left-side vertical menu, select the Schema view.
- Import Schema:
- Click the button located to the right of the search bar.
- From the list, select the Import Schema option.
- Choose JSON Source:
- Paste the JSON content directly or import a JSON document from the local file system.
- Specify a meaningful Name for the schema.
- Confirm the schema import by clicking the OK button.
Configuring JSON Schema for Map or Flow:
- Define Schema Structure:
- Ensure that your JSON schema reflects the structure of the MongoDB documents.
- If handling multiple documents together, use a JSON array of JSON objects as the top-level element.
- For processing one document at a time, use a JSON object as the top-level element.
- Schema for Retrieving/Inserting Entire Documents:
- If documents need to be retrieved or inserted in their entirety without
processing individual fields:
- Use a simple schema with a single unbounded text item as the root type.
- If documents need to be retrieved or inserted in their entirety without
processing individual fields:
- JSON Instance Document Format:
- For representing a single document in a collection, use the
format:
{ JSON-document-data }
For example:{ "customer": "Company X", "location": "Europe" }
- For representing multiple documents in a JSON array, use the
format:
[ { JSON-document-data }, { JSON-document-data } ]
For example:[ { "customer" : "Company X", "location" : "Europe" }, { "customer" : "Company Y", "location" : "North America" } ]
- For representing a single document in a collection, use the
format:
- Command Line Generation:
- When compiling a map or flow using MongoDB cards or nodes, the -SDF command is automatically included in the generated command line if the operation implies single JSON instance usage.
- Default Processing for Multiple Documents:
- By default, the MongoDB adapter processes instance documents as multiple-document arrays (multiple-document format). There is no corresponding command option.