Document Query (External)
The listener will serve get queries with the required data and allow external system to provide their own query structures during the call. Here any simple GET query on the end point till result in the full collection data to be served, however a document can be posted into this listener to explain to Utopia how you would like the result. “IncludeHeader”: Boolean field to include document system meta data or not “FilterDefinition”: include a mongo filter definition here to filter out the required documents. this needs to be in an exit string type, although most queries will work directly as shown below.
“PipelineStageDefinitions”: include an aggregation pipeline to manipulate the output data to suit your needs.
“Sort”: sort your results using a particular field.
All queries need to include Content-Type and/or Accept to explain how what format the body and response needs to be in.
In this example, the result will give all the documents in the collection created after the document with ObjectId: 61dfdbbcb700290001014f21
{
"IncludeHeader": true,
"FilterDefinition": "{_id: { $gt: ObjectId('61dfdbbcb700290001014f21')}}",
"Sort": [
{
"Field": "_id",
"Direction": 1
}
]
}
In this example we are doing the same function but using the createdOn date to filter against:
{
"IncludeHeader": true,
"FilterDefinition": "{ '_header.createdOn': {$gte: ISODate('2021-04-01T09:16:08.8260000Z')}}",
"Sort": [
{
"Field": "_header.createdOn",
"Direction": 1
}
]
}
Here is another example just querying specific fields:
{
"IncludeHeader": false,
"FilterDefinition": "{ 'status': 'Active'}"
}
Another example adding a page size to the call to limit documents in the response
{
"IncludeHeader": true,
"Sort": [
{
"Field": "_id",
"Direction": 1
}
],
"PageSize": 1
}
Last updated