如何从meteor subscribe变量中获取值

时间:2016-05-08 10:10:44

标签: mongodb meteor

服务器:

dbHandleremp = new Meteor.Collection("emp");
Meteor.publish("emp", function(email) {  
 return dbHandleremp.find({ 
 "email": email 
});
});  

客户:

dbHandleremp = new Meteor.Collection("emp");
var dbempQuery =Meteor.subscribe('emp', "a@a.com", function() {
dbHandleremp.find(); 
});
console.log(dbempQuery);

如何从“dbempQuery”中获取值

2 个答案:

答案 0 :(得分:1)

if(Meteor.subscribe('emp', "a@a.com").ready()){
  var result = emp.find({}).fetch();
  console.log(result);
}

答案 1 :(得分:0)

Meteor.subscribe("emp", "a@a.com",{
  onReady: function () {
     var dbempQuery = emp.find({}).fetch();
     console.log(dbempQuery);
  }
});