yozawiratama
yozawiratama

Reputation: 4318

meteor subscribe/publish with parameter return 0

i studying subscribe and publish now. this is my subscribe.js on client

var userhandle = null;

Deps.autorun(function () {
    userhandle = Meteor.subscribe('user', 1);
    if(userhandle.ready()){
    console.log("ready");
    }

});

and this my publish.js on server

Meteor.publish('user', function (amount) {

    return Users.find({
        limit: amount
    });
});

i wish i can publish "Users" data as much i need.

after i run this, nothing error, and i do

Users.find().fetch()

on browser console, but it return 0 length Why this happen? how to make this works?

Update : Iam not use meteor.users I just use simply collection Users = new Meteor.collection("USER");

Upvotes: 0

Views: 123

Answers (1)

richsilv
richsilv

Reputation: 8013

Your find query in the publish function is not formed correctly - if you're specifying options, you need a query object, even if it's an empty one:

return Users.find({}, {
    limit: amount
});

Give that a go.

Upvotes: 2

Related Questions