publish subscribe - Meteor subscription _id through array -


i making list right now.

users able search , click on searched item add corresponding id list.

this following code have written.

template.searcheditem.events

'click .addtolist': function (event, template) {     event.preventdefault();      // _id of list     var listid = template.parentdata(1)._id;     console.log(listid);      // _id of searched item     var companyid = this._id;     console.log(companyid);      meteor.call('addtolist', listid, companyid, function (error, result) {      if (error) {       } else {       }     });   } 

method

meteor.methods({   addtolist: function (listid, companyid) {     check(listid, string);     check(companyid, string);      var add = lists.update({       _id: listid,       companies: {$ne: companyid}     }, {       $addtoset: {companies: companyid},       $inc: {companycount: 1}     });      return add;   } }); 

object of list

list = {   _id: listid,   name: nameoflist   companies: [     // _ids of added companies     0: 'addedcompanyid',     1: 'someotheraddedcompanyid',     , forth...   ] } 

from here, trying make sub/pub shows companies added in list.companies.

i have no idea on how..

i thinking of this.

<template name = "list">   {{#each addedcompanies}}     here   {{/each}} </template>  template.list.helpers({   addedcompanies: function () {    companies = this.companies;    return clients.find(/*something here*/);   } }); 

everything i've written works far. lost in returning cursor array of _ids.

update

simply put, can return cursor multiple _ids query??

yes, can return cursor list of ids. can return cursor on valid query.

meteor.publish('clientsfromcompanyids', function(companyids) {   return clients.find({companyid: {$in: companyids}}); }); 

is looking for?


Comments