Hi there
I have two collection
Users
{
"_id" : ObjectId("57ee0b8f7c705870a0196ee3"),
"username" : "John",
"email" : "a3_prince@naver.com",
"password" : "qus900!!"
}
and Posts
{
"_id" : ObjectId("57ee2b557c705870a0196ef6"),
"title" : "How to get embedded object in mongodB shell",
"contents" : "You can connect like so:\n\nvar database = new ",
"regId" : "9TKD5mo6qM5jFzX3S",
"createdAt" : "2016-09-30-09-11",
"groupId" : "5onHGJKyJvq63Lt3J",
"viewCount" : NumberInt(100),
}
and I wanna post two collection
posts.title, users.username, viewCount
So I did publish like this
if (Meteor.isServer) {
Meteor.publish('posts', function(groupId) {
var post_regIds, user_ids;
post_regIds = posts.find({
groupId: groupId
}, {
fields: {
regId: 1
}
});
user_ids = post_regIds.map(function(p) {
return p.regId;
});
return [
posts.find({
groupId: groupId
}), Meteor.users.find({
_id: {
$in: user_ids
}
})
];
});
}
anyway How can I post two more collections?
Someone help me ~