I’m trying to use GitHub - robfallows/tunguska-reactive-aggregate: Reworks jcbernack:reactive-aggregate for ES6/ES7 and Promises with $lookup.
Is it possible to publish a reactive aggregate on such structure :
const ContactsSchema = new SimpleSchema({
userId: {
type: String,
label: 'The ID of the user',
},
followedBy: {
type: Array,
label: 'informations about user\'s followers',
optional: true,
defaultValue: [],
},
'followedBy.$': UserSchema,
blocked: {
type: Array,
label: 'informations about users blocked by user',
optional: true,
defaultValue: [],
},
'blocked.$': UserSchema,
...
const UserSchema = new SimpleSchema({
userId: {
type: String,
label: 'userId of User',
},
since: {
type: Date,
label: 'date since last operation on record',
},
});
Standard publish :
Meteor.publish("contacts.byId", userId => {
return Contacts.find({ userId: userId });
});
I would like that the published Contacts resolves each userId in followedBy, blocked arrays as selected values of Meteor.users (username, avatar…) in the same way a graphQL request would do.
[ {
userId: xxxx,
followedBy: [
{ userId: u1, username: n1, avatar: a1, since: date1},
{ userId: u2, username: n2, avatar: a2, since: date2}...],
blocked: [
{ userId: u3, username: n3, avatar: a3, since: date3}
]
}
I’m not familiar enough with $lookup to find a way to solve this, even know if it is possible or not.
Unfortunatly Rob doesn’t have enough available time to help and invited me to post here
Thank you