Adapter for MongoDB 9.12 | webMethods Adapter for MongoDB Documentation | webMethods Adapter for MongoDB Installation and User’s Guide Documentation | Adapter Services | Examples of Designing Filters on an Array of Embedded Documents
 
Examples of Designing Filters on an Array of Embedded Documents
The examples in this section show the filters created in Adapter services or notifications to query data from an array of embedded documents.
The following image is a sample data in MongoDB.
Specifying a query condition on a nested field in the array of embedded documents
The following example shows a query condition that returns all the documents where the array has at least one embedded document that contains the field that matches the query condition.
The following image shows a query condition that returns all the documents where the items array has at least one embedded document that contains the field qty whose value is less than or equal to 5.
Specifying a query condition on a nested field in the array of embedded documents using the array index
The following example shows a query condition that returns all the documents where the array has as its first element a document that contains the field that matches the query condition.
The following image shows a query condition that returns all the documents where the items array has as its first element a document that contains the field qty whose value is equal to 5.
Specifying a query condition with a combination of nested fields in the array of embedded documents
The following example shows a query condition that returns all the documents where the array has at the least one embedded document(not necessarily the same embedded document but existing within the same array) that matches both the conditions.
The following image shows a query condition that returns all the documents where the items array has one embedded document that contains the field itemId whose value is equal to 004 and another embedded document (within the same array) that contains the field qty whose value is equal to 10.
Specifying an array of query conditions in the array of embedded documents
The following example shows an array of query conditions that returns all the documents within an array that exactly matches the query conditions.
The following image shows a query condition that returns all the documents where the items array has one embedded document that contains the field itemId whose value is equal to 002 and qty is equal to 10 and the second embedded document in the same array that contains the field itemId whose value is equal to 004 and qty is equal to 15.