-
Notifications
You must be signed in to change notification settings - Fork 5.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
publish interface doesn't clone its arguments #1750
Comments
This seems like a bug but you haven't provided enough details to investigate it. Please see https://github.com/meteor/meteor/wiki/Contributing-to-Meteor#reporting-a-bug-in-meteor I'll reopen the issue if you provide a reproduction. |
Reproduced: |
Hi Lior, http://docs.meteor.com/#observe_changes If you're looking for a pattern for incrementing some basic analytics, and keeping a count of how many books are in your collection, take a look at line 52 from the topicsPage controller and line 94 from the postsPage controller in GroupThink BBS. https://github.com/awatson1978/groupthink/blob/master/client/controllers/workflow/topicsPage.js Instead of .observeChanges, you probably want to be using $inc operators, like so: // first example
Topics.update(Session.get('forum_topic_id'), {$inc: {replies: 1 }});
// second example
Topics.update(this._id, {$inc: { views: 1 }, $set: { lastPostId: Meteor.userId(), lastPostBy: Meteor.user().profile.name }}); You touched on the right pattern by thinking you'd need a BookStats.update(Session.get('selected_book_id'), {$inc: {views: 1 }}); |
Hey Abigail, You'd see that calling observeChanges within a publish() function is what On Sun, Jan 19, 2014 at 5:09 PM, Abigail Watson notifications@github.comwrote:
|
Thanks, verified. |
Fix will be in 0.7.1. Thanks for the reproduction; it made the issue very clear. |
I've tried to replicate the example of the counts-by-room from the meteor docs, but instead of
I used
And I've initialized the collection with the same object, as required before calling self.ready().
The collection is indeed initialized properly on the client side, but when the "added" event is called on the published collection, the code fails to update the "counts" collection.
I've beaten around the bush for a couple of hours, before calling this.changed twice - to finally get the "collection" to be updated as expected:
I've tried using $set to update the value of a specific color, but it simply created a key called "$set" in the collection, and assigns the vol object to it.
The text was updated successfully, but these errors were encountered: