Created
February 22, 2013 10:07
-
-
Save svasva/5012259 to your computer and use it in GitHub Desktop.
Meteor publish-with-relations complex use
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Meteor.publish('bike', function(id) { | |
return Meteor.publishWithRelations({ | |
handle: this, | |
collection: Bikes, | |
filter: id, | |
mappings: [ | |
{ | |
key: 'userId', | |
options: { fields: config.users.publicFields }, | |
collection: Meteor.users | |
}, { | |
reverse: true, | |
key: 'bikeId', | |
collection: Pictures | |
}, { | |
reverse: true, | |
key: 'bikeId', | |
collection: Comments, | |
options: { | |
sort: { createdAt: -1 } | |
}, | |
mappings: [ | |
{ | |
key: 'userId', | |
collection: Meteor.users, | |
options: { fields: config.users.publicFields } | |
} | |
] | |
}, { | |
reverse: true, | |
key: 'bikeId', | |
collection: BikeParts, | |
mappings: [ | |
{ | |
key: 'partId', | |
collection: Parts, | |
mappings: [ | |
{ key: 'typeId', collection: PartTypes }, | |
{ key: 'vendorId', collection: PartVendors } | |
] | |
}, { | |
key: 'userId', | |
collection: Meteor.users, | |
options: { fields: config.users.publicFields } | |
} | |
] | |
} | |
] | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment