Skip to main content

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:

ValueDescriptionExample
connectionStringConnection string for your source87E4lvPf83gLK8eKapH6Y0YqIFSNbFlq62uN9487
DatabaseName of your MongoDB databasetest
CollectionName of your MongoDB collectionArticle
TypeMethod used to retrieve datafind
QueryQuery for retrieving data. Example returns data where price < $10"{ 'Price': { '$lt': 10 } }"
ProjectionProjection for flattening source document{ "Name": 1, "Price": 1, "Color": "Details.Color", "Size": "Details.Size", "Stock": 1, "Details": 1 }
Column NameNames of your source columnsid, name, price, colour, size, stock, $, Details
dataTypeData type of your source columnText, Text, Number, Text, Text, Number, Text, Text
isMandatoryWhether the column is mandatoryfalse
validateDataWhether column data needs validationfalse

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=""{ &quot;Price&quot;: { &quot;$lt&quot;: 10 } }"" projection=""{
&quot;Name&quot;: 1,
&quot;Price&quot;: 1,
&quot;Color&quot;: &quot;Details.Color&quot;,
&quot;Size&quot;: &quot;Details.Size&quot;,
&quot;Stock&quot;: 1,
&quot;Details&quot;: 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>