-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
More Configuration Example #5
Comments
@jura-b the mixin is actually quite robust, but at the same time complex... Do you have a specific result in mind? I can help on that... adding all types of examples might also confuse you |
@jonathan-casarrubias
I want the average of result.score. How does the config look like? Thank you in advance! |
@jura-b the stats mixing results in series of data expected to be passed to any chart, said that. I won't provide the functionality aside of creating series, for instance: If you only want to get the average from a couple of records. What actually does is to create series of data based on time: Lets say you have the following records { title: "Example 1", result: { score: 10 }, createdAt: '2017/07/15' } *Note date should actually be ISODate (Recommended use of loopback-ds-timestamp-mixin) When using the stats mixing it will return series which in this use case one of the datum would be 12.5 from the average in day 15. To achieve that you would configure as follows: "mixins": {
"Stats": [
{
"method": "average", // This can be whatever you want
"endpoint": "/average", // This also can be whatever you want
"description": "A Description for your average method", // As well as this
"type": "model", // We will calculate over this model, not from a related model
"count": {
"on": "createdAt", // This creates time based series
"by": "result.score", // will count by result.score
"avg": true // This will return the average from result.score (12.5 at Aug 15)
}
}
]
} I hope this clarifies your question and also the mixing functionality. Regards |
@jonathan-casarrubias Really appreciate your help! |
@jonathan-casarrubias
You already answer how to config to find the avg score across records grouped by "createdAt".
Thank you in advance, |
Could you provide more example of each type of boot option, please?
The text was updated successfully, but these errors were encountered: