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:
  1. Open Link project in Design Server UI workspace.
  2. Navigate to Schema View: In the left-side vertical menu, select the Schema view.
  3. Import Schema:
    • Click the button located to the right of the search bar.
    • From the list, select the Import Schema option.
  4. 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.
  5. Confirm the schema import by clicking the OK button.
Configuring JSON Schema for Map or Flow:
  1. 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.
  2. 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.
  3. 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"
          }
      ]
      
      
  4. 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.
  5. 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.