-
Notifications
You must be signed in to change notification settings - Fork 0
1.2.1 Cross Model Aggregations
- All Cross-Model aggregations are automatically scoped to the request feedId, any filtering is on top of this.
- Aggregation can be performed on any fields that are numerical, whole or decimal, across models.
- All aggregation is defined by url encoded json.
- You can aggregate on multiple fields from different models.
- There is no projection of fields for output.
- GroupBy can be performed on a single field basis.
- Output is similar to single-model aggregation.
- Available aggregate query options are:
- function (AVG, SUM, COUNT)
- groupBy (List of Cross Model Grouping Configurations, currently limiited to 1.)
- groupBy (Array of strings defining field(s) to group by. If the field is equal across models a singular shorthand like ["userId"] can be used. For varying you must prepend by model name pluralized, e.g. ["comments.providerId","likes.likeObjectId"])
- groupByUnit (Direction of value sort, asc or desc. DESC is default, this is applied to every groupBy element across models)
- groupByRange (Count of objects to return, max 100, min 1, default 10, this is applied to every groupBy element across models)
- groupingSortOrder (Direction of value sort, asc or desc. DESC is default, this is applied to every groupBy element across models)
- groupingListLimit (Count of objects to return, max 100, min 1, default 10, this is applied to every groupBy element across models)
- groupByUnit (Unit to Range Grouping, available values are: INTEGER (For numbers), DATE (For dates), default is nothing. Only number and date fields are supported)
- groupByRange (Amount to range-group upon, available values are: Some x integer for numbers, HOUR, TWELVE_HOUR, DAY, WEEK, MONTH, YEAR for Dates.
- groupBySortOrder (Direction of value sort, asc or desc. DESC is default)
- groupByListLimit (Count of objects to return, max 100, min 1, default 10)
{
"function":"COUNT",
"groupBy": [
{
"groupBy": ["userId"]
}
]
}
{
"function":"SUM",
"groupBy": [
{
"groupBy": ["feedId"],
"groupingSortOrder":"asc",
"groupingListLimit":10
}
]
}
{
"function":"COUNT",
"groupBy": [
"groupBy":["comments.registrationDate", "likes.createdAt"],
"groupByUnit":"DATE",
"groupByRange":"WEEK",
"groupingSortOrder":"asc",
"groupingListLimit":10
]
}
aggregate=%7B%22function%22%3A%22COUNT%22%2C%22groupBy%22%3A%5B%7B%22groupBy%22%3A%5B%22userId%22%5D%7D%5D%7D
aggregate=%7B%22function%22%3A%22SUM%22%2C%22groupBy%22%3A%5B%7B%22groupBy%22%3A%5B%22feedId%22%5D%2C%22groupBySortOrder%22%3A%22asc%22%2C%22groupByListLimit%22%3A10%7D%5D%7D
aggregate=%7B%22function%22%3A%22COUNT%22%2C%22groupBy%22%3A%5B%22groupBy%22%3A%5B%22comments.registrationDate%2Clikes.createdAt%22%5D%2C%22groupByUnit%22%3A%22DATE%22%2C%22groupByRange%22%3A%22WEEK%22%2C%22groupBySortOrder%22%3A%22asc%22%2C%22groupByListLimit%22%3A10%5D%7D
- Available projection query options are:
- models (String array of models to aggregate upon, must be pluralized)
- fields (String array of fields to do aggregation on, prepended by pluralized model name)
- fields must be empty for COUNT operations, due to being irrelevant
{
"models":["comments", "likes"]
}
{
"models":["feedItems", "comments"],
"fields":["feedItems.likeCount","comments.likeCount"]
}
projection=%7B%22models%22%3A%5B%22comments%22%2C%20%22likes%22%5D%7D
projection=%7B%22models%22%3A%5B%22feedItems%22%2C%20%22comments%22%5D%2C%22fields%22%3A%5B%22feedItems.likeCount%22%2C%22comments.likeCount%22%5D%7D
- Available filter query options are:
- models (Object array of models to filter upon)
- model (String name of model to filter upon, pluralized.
- fields (Object array of fields to filtre upon)
- field (String name of field to fiter upon)
- parameters (Object array of filtering parameters, params are same as normal filtering)
- models (Object array of models to filter upon)
{
"models":[
{
"model":"feedItems",
"fields":[
{
"field":"providerName",
"parameters":[
{
"eq":"FACEBOOK"
}
]
}
]
}
]
}
{
"models":[
{
"model":"comments",
"fields":[
{
"field":"reply",
"parameters":[
{
"eq":true
}
]
},
{
"field":"likeCount",
"parameters":[
{
"gt":10000
},
{
"lt":50000
}
]
}
]
},
{
"model":"likes",
"fields":[
{
"field":"userId",
"parameters":[
{
"eq":"4554b1eda02f902beea73cd03c4acb4"
},
{
"eq":"6ab6c2a487d25c6c314774a845690e6",
"type":"or"
}
]
}
]
}
]
}
projection=%7B%22models%22%3A%5B%7B%22model%22%3A%22feedItems%22%2C%22fields%22%3A%5B%7B%22field%22%3A%22providerName%22%2C%22parameters%22%3A%5B%7B%22eq%22%3A%22FACEBOOK%22%20%7D%5D%7D%5D%7D%5D%7D
projection=%7B%22models%22%3A%5B%7B%22model%22%3A%22comments%22%2C%22fields%22%3A%5B%7B%22field%22%3A%22reply%22%2C%22parameters%22%3A%5B%7B%22eq%22%3Atrue%7D%5D%7D%2C%7B%22field%22%3A%22likeCount%22%2C%22parameters%22%3A%5B%7B%22gt%22%3A10000%7D%2C%7B%22lt%22%3A50000%7D%5D%7D%5D%7D%2C%7B%22model%22%3A%22likes%22%2C%22fields%22%3A%5B%7B%22field%22%3A%22userId%22%2C%22parameters%22%3A%5B%7B%22eq%22%3A%224554b1eda02f902beea73cd03c4acb4%22%7D%2C%7B%22eq%22%3A%226ab6c2a487d25c6c314774a845690e6%22%2C%22type%22%3A%22or%22%7D%5D%7D%5D%7D%5D%7D