Sync client collection updates with the server collection


#1

I’m publishing record set from ‘users’ collection to the ‘friends’ client collection.
I want to update ‘friends’ collection at the client and that the updates will be applied at the server to the ‘users’ collection.

I realised that it isn’t possible and I’m getting the error: update failed: Method not found.

I created Meteorpad example with the leaderboard
I publish “myPlayers” collection and I’m trying to increase the points.

Does someone have a solution for this? or a better approach?
I want to avoid from create Meteor.method and a different “stub” at the client that will use the “friends” collection.


#2

you are probably looking for overriding _publishCursor,
part “Client only collections” of https://medium.com/@Dominus/meteor-tips-and-workarounds-b791151ce870


#3

I don’t get it. Why is the MyPlayers collection declared only client-side? What is the purpose of the Players collection?


#4

MyPlayers is meaningless I just add the Meteorpad for demonstrate that it will not work


#5

How did you get it? I mean how your publish cursor know that data from “Users” should be megred with “Friends” on the client?

Your client side collection doesnt live on a server side. Your MyCollection.update(...) = Meteor.call('/mycollection/update/', ...) - Meteor makes it for you when you define collection on a server


#6

I used the this.added / this.changed / this.removed publish api, look at the meteor pad