There are 4 types of queries that are supported:
A query that gets an entire collection without any filtering. We have a few collections that represent internal data that doesn't need to be filtered by company. For these your json object would look like:
{
"name": "name_of_collection_you_want_to_get",
"filter": "none",
}
A query that uses a lookback for a number of days. Some of the collections that don't need a company filter are quite large and it's not necessary to wrap up gigs and gigs of historical data for development. So instead we can provide a lookback to reduce the number of documents that get pulled.
{
"name": "name_of_collection_you_want_to_get",
"filter": "lookback",
"lookback": {
"days": 7,
"field": "created_at"
}
}
The lookback attributes are required when defining this type
A query that can be filtered by a company_id
field.
For these your json object would look like:
{
"name": "name_of_collection_you_want_to_get",
"filter": "company"
}
This will tell our go app to filter the collection on the Bonusly company_id
A query that uses the mongodb aggregate pipeline with a lookup
This one is a little more complex. Many collections do not have a company_id
but they do have an association with a record that does have a company_id
For these your json object would look like:
{
"name": "name_of_collection_you_want_to_get",
"filter": "aggregate",
"pipeline_attributes": {
"starting_collection": "associated_collection_that_has_company_id",
"stages": [
{
"name": "$lookup",
"attributes": {
"from": "name_of_collection_you_want_to_get",
"localField": "_id",
"foreignField": "id_stored_on_the_collection_you_want_that_matches_the_starting_collection",
"as": "name_of_collection_you_want_to_get"
}
},
{
"name": "$unwind",
"attributes": "$name_of_collection_you_want_to_get"
},
{
"name": "$replaceRoot",
"attributes": { "newRoot": "$name_of_collection_you_want_to_get" }
}
]
}
}
The pipeline should start from a collection that has a company_id
, this first filter is automatically included in the app code. The pipeline attibutes are requred for this type.
Removing a collection from the image is as simple as deleting the object that defines it's query in the JSON config file.