Skip to content

Element <mongodb>

Purpose: Declare a named MongoDB client used by source and target operations.

Why: Use it when a descriptor reads, writes, clears, or aggregates MongoDB collections.

Example

1
<mongodb id="customer-mongo"/>

Decision guide

Business value: Gives collection reads, writes, aggregation, and reviewed mutations one named client contract.

  • Use when

    • The source or target is a MongoDB database or collection.
  • Choose another approach when

    • The data is relational, file-based, or broker-based.
  • Prerequisites

    • Provide reachable topology and secret-backed credentials for runtime execution.
  • Alternatives

    • Use database for relational tables and SQL. (See: <database>)

Complete examples

Declare a MongoDB client for collection-oriented assembly

Use a named MongoDB client when generated documents and aggregate selectors share one database and authentication contract; inject credentials through the deployment's secret-backed configuration.

mongodb-client/datamimic.xml
1
2
3
4
5
6
7
<setup>
    <mongodb id="mongodb"/>
    <generate name="customer_events" count="10" target="LogExporter,mongodb" type="events">
        <id name="event_id" generator="IncrementGenerator"/>
        <key name="kind" constant="CUSTOMER_CREATED"/>
    </generate>
</setup>

Rules and invalid combinations

No additional element-specific rules. Required attributes, types, and supported values are shown below.

Allowed parents / Allowed children

Allowed parents: else, else-if, if, setup, while

Allowed children:

None

Extension attributes: The declared attributes are complete. This element also accepts runtime-defined vendor extensions, which intentionally have no static completion.

  • Choose a source and target — Guides users and agents from an input ownership boundary and intended side effect to one bounded source and target contract.

Attributes

Show all 8 attributes

database

Database/collection namespace to connect to.

optional; string.

environment

Optional environment label for this MongoDB config.

optional; string; Default: null.

host

Hostname or connection string for MongoDB.

optional; string.

id

MongoDB ID for accessing the database in the script context.

required; string.

password

Password for authentication.

optional; string; Default: null.

port

Port number for MongoDB.

optional; string.

system

Optional platform system identifier used to resolve environment properties.

optional; string; Default: null.

user

Username for authentication.

optional; string; Default: null.