You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
varusers=yieldEvent.findAll({...},{with: [// load all comments, what we currently support'comments',// load only comments with category_id = 1 (shorthand for '=='){comments: {category_id: 1}},// load only comments with category_id > 1{comments: {category_id: {'>': 1}}}]});
Support for adding calculated/aggregate properties
varevents=yieldEvent.findAll({...},{with: [// add `review_count` property to each event{review_count: {'review.rating': 'count'}},// add `review_average` property to each event{review_average: {'review.rating': 'average'}},]});
I'm thinking rather than {comments: {category_id: 1}} we should do:
{
relation: 'comments', // "relation" is either the "localField" or name of the related resource
query: { category_id: 1 } // "query" follows JSData's query syntax
}
hmm, it's more verbose (which might not be a bad thing). I had all intentions of support all of JSData's query syntax with {comments: /* query syntax */}
What are you thoughts on the calculated/aggregate properties?
The issue with {comments: /* query syntax */} is it has to be parsed using something like Object.keys, whereas { relation: 'comments' ... gives instance information about which relation we're dealing with.
Maybe with isn't the right place to specify aggregations that should be included in the result? with is an array, seems like we need an object here, e.g.
var events = yield Event.findAll({...}, {
// This object is essentially "merged" into the result
// This seems fully expressive
compute: {
// add `review_count` property to each event
review_count: {
relation: 'review',
query: {}, // optional,
op: 'count'
},
// add `review_average` property to each event
review_average: {
relation: 'review',
query: {}, // optional selection query
op: 'average',
field: 'rating'
}
}
});
Activity
jmdobry commentedon Feb 16, 2016
I'm thinking rather than
{comments: {category_id: 1}}we should do:techniq commentedon Feb 16, 2016
hmm, it's more verbose (which might not be a bad thing). I had all intentions of support all of JSData's query syntax with
{comments: /* query syntax */}What are you thoughts on the calculated/aggregate properties?
jmdobry commentedon Feb 16, 2016
The issue with
{comments: /* query syntax */}is it has to be parsed using something likeObject.keys, whereas{ relation: 'comments' ...gives instance information about which relation we're dealing with.Maybe
withisn't the right place to specify aggregations that should be included in the result?withis an array, seems like we need an object here, e.g.