Description
The MongoDBInsertReceiver is used to insert a Domain's generated data in a JSON file directly into a MongoDB collection.
In This Article
- Receiver Parameters
- Sample Database Connectivity Properties file
- URI Connection String Format for Connecting to any MongoDB Database
- Receiver Attribute Property Keys
Receiver Parameters
The following parameters can be defined for the MongoDBInsertReceiver. Items with an asterisk (*) are required:
- resourceName* - Defines the name of the resource that contains the database connection information on a user's local machine.
- databaseName* - The name of the database to access.
- collectionName* - The name of the MongoDB collection to insert rows into.
- truncate* - Truncates the collection before inserting rows.
- jsonFilePath* - Defines the path to the JSON file.
- jsonSubDir - Defines the sub-directory within the JSON file path where the JSON file for the Receiver exists.
- jsonFileName - Defines the name of the particular JSON file within the JSON file path that needs to be read for its content and inserted into the Mongo DB collection. The Receiver parameter 'extension' value will be ignored if the value of the jsonFileName is given.
- extension - If the Receiver parameter 'jsonFileName' is not given a value, then MongoDBInsertReceiver looks for all the files having given extension within the JSON file path for inserting data into Mongo DB collection.
Sample Database Connectivity Properties file
A config.properties file is required to connect to a MongoDB database. An example file is shown below:
host=localhost portNumber=27017 user=sampleOwner password=somePassword
URI Connection String Format for Connecting to any MongoDB Database
To use the URI connection string, users need to configure their config.properties file to contain only the url property, which has the following format:
mongodb://[username:password@]host[:port][/[defaultauthdb][?options]]
Example
Here is an example config.properties file with the url property:
url=mongodb://user:password@localhost:27017/admin
Replace the user, password, host, and port information with your DB specific details. In the above example, the Receiver is going to validate the mentioned user against the admin database for the MongoDB running on localhost at port 27017.
Receiver Attribute Property Keys
The Receiver defines three property keys that can be modified on any of its associated Domain Attributes:
- columnName - Defines the name of the column as it is in the actual database table.
- columnType - Defines the column data type. The default is "String"
- include - Defines if the column should be included or excluded from the insert statement.