Meteor-Community-Packages / ground-db

GroundDB is a thin layer providing Meteor offline database and methods
https://atmospherejs.com/ground/db
MIT License
572 stars 77 forks source link

Updating Grounded Collection + syncing with server #206

Open vv001 opened 6 years ago

vv001 commented 6 years ago

Hello,

I am currently able to retrieve a number of Orders by use of following method and store it in a Grounded Collection:

public initGroundedCollectionOrders() { if(Meteor.isClient) { console.log('METEOR IS CLIENT'); this.newOrders = new Ground.Collection('orders', { cleanupLocalData:false }); this.newOrders.observeSource(Orders.find()); Meteor.subscribe('orders', { onReady() { this.newOrders.keep(Orders.find({},{reactive: true})); } }); this.newOrders.once('loaded', ()=> {console.log('loaded'); }); } }

I want to update the status of an order which is stored in "this.newOrders". I do it by the following:

public updateGroundedOrder(orderid: number, status: string) { this.newOrders.update({ _id: orderid }, { $set: { status: status } }); }

This seems to update the order in the Grounded collection, but doesn't sync it with the server. How can I make sure that when the specific order in the Grounded Collection 'orders' is updated, it in turn is synced and updated on the server side?