MongoDB collection source example
Example data
The following is an example of data we want to sync out of MongoDB.
test> db.Articles.find()
[
{
_id: ObjectId("63d812afd755fcdeed234402"),
Name: 'Shirt',
Price: 19.95,
Details: { Color: 'Red', Size: 'Medium' },
Stock: 12
},
{
_id: ObjectId("63d8137bd755fcdeed234403"),
Name: 'Shirt',
Price: 9.95,
Details: { Color: 'White', Size: 'Small' },
Stock: 61
}
]
XML example
This example XML uses the following values:
Value | Description | Example |
---|---|---|
connectionString | Connection string for your source | 87E4lvPf83gLK8eKapH6Y0YqIFSNbFlq62uN9487 |
Database | Name of your MongoDB database | test |
Collection | Name of your MongoDB collection | Article |
Type | Method used to retrieve data | find |
Query | Query for retrieving data. Example returns data where price < $10 | "{ 'Price': { '$lt': 10 } }" |
Projection | Projection for flattening source document | { "Name": 1, "Price": 1, "Color": "Details.Color", "Size": "Details.Size", "Stock": 1, "Details": 1 } |
Column Name | Names of your source columns | id , name , price , colour , size , stock , $ , Details |
dataType | Data type of your source column | Text , Text , Number , Text , Text , Number , Text , Text |
isMandatory | Whether the column is mandatory | false |
validateData | Whether column data needs validation | false |
XML example
<BatchDataSyncConfig name=""MongoDB Data Source Example"" version=""1.0.0""
xmlns=""http://www.cinchy.co"">
<MongoCollectionDataSource connectionString=""AI+FJVIMO1HP/CkZ5yphXeJ01wjH/4ilJ8xAIPPDyxvYq0oiYnVBQrzaq2Cp5942poeDdOp"" database=""test"" collection=""Articles"" type=""find"" query=""{ "Price": { "$lt": 10 } }"" projection=""{
"Name": 1,
"Price": 1,
"Color": "Details.Color",
"Size": "Details.Size",
"Stock": 1,
"Details": 1
}"">
<Schema>
<Column name=""_id"" dataType=""Text"" trimWhitespace=""true"" isMandatory=""false"" validateData=""false""/>
<Column name=""Name"" dataType=""Text"" trimWhitespace=""true"" isMandatory=""false"" validateData=""false""/>
<Column name=""Price"" dataType=""Number"" isMandatory=""false"" validateData=""false""/>
<Column name=""Color"" dataType=""Text"" trimWhitespace=""true"" isMandatory=""false"" validateData=""false""/>
<Column name=""Size"" dataType=""Text"" trimWhitespace=""true"" isMandatory=""false"" validateData=""false""/>
<Column name=""Stock"" dataType=""Number"" isMandatory=""false"" validateData=""false""/>
<Column name=""$"" dataType=""Text"" trimWhitespace=""true"" isMandatory=""false"" validateData=""false""/>
<Column name=""Details"" dataType=""Text"" trimWhitespace=""true"" isMandatory=""false"" validateData=""false""/>
</Schema>
</MongoCollectionDataSource>