Reputation: 9
Been a bit stuck today and found a bunch of related topics, but still didn't manage to fix it. I'm kinda new to Meteor and might not been doing it in the right way but got autopublish removed.
I'm creating the collection as a const in lib/import folder which is shared with client/server. Next, I'm calling a server method inside a Async to insert the data into the collection. So far so good, I think (I see the data inside db mongo).
Now in the client.js, I want to handle each data related to a user, and then append it to the template or do some other stuff.
// SERVER
Meteor.publish("pipeline", function() {
var data = pipeline.find({}, {fields: {userID:this.userID}}).fetch();
return data;
});
// CLIENT
var loadCurrentPipeLineUser = Meteor.subscribe('pipeline');
var data = pipeline.findOne({userID: Meteor.userId()});
console.log(loadCurrentPipeLineUser);
console.log(data);
Both loadCurrentPipeLineUser
and data
return undefined. The output of loadCurrentPipe
(which I think means undefined) is:
On server side, inside the publish, it prints everything right on the console.
Upvotes: 0
Views: 64
Reputation: 3614
Publish it without .fetch()
Meteor.publish("pipeline", function() {
return pipeline.find({}, {fields: {userID:this.userID}});
});
Because publish returns a cursor.
Upvotes: 1