Meteor-Community-Packages / ground-db

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

Updating Collection does not effect view while offline #146

Closed SinAndTonic closed 3 months ago

SinAndTonic commented 8 years ago

So I have groundDB running so that my app will work offline. It is set up like the following:

Orders = new Mongo.Collection("orders");

Ground.Collection(Orders);

And that collection contains the following Schema (simplified for explanation):

Orders.attachSchema(new SimpleSchema({
  completed: {
    type: Boolean,
    defaultValue: false
  }
}));

My app shows only documents that are marked {complete:false}:

Template.currentOrder.helpers({
    currentO: function(){
        return Orders.find({completed: false});
    }})

and there is a button to mark documents as {complete:true} via a method which is also cached:

if ( Meteor.isServer ) {

Meteor.methods({
  updateAll: function(){
    Orders.update({},{$set:{'completed':true}},{multi:true});

  },
});
}

if ( Meteor.isClient ) {
Meteor.startup(function() {
  if ( Meteor.isClient ) {
    Ground.methodResume([
      '/' + self.name + '/insert',
      '/' + self.name + '/remove',
      '/' + self.name + '/update',
      'updateAll'
    ]);
  }
});
}

The problem is that when a document is updated to be {complete:true}, it is still displayed by the app. Im not sure how to get the app to respond to the changes in the instance of GroundedDB. As a side note, as soon as the connection is resumed the Collection is updated and the documents now marked as {complete:true} disappear as expected.

Any help would be greatly appreciated :)

raix commented 8 years ago

I've released 2.0.0-alpha.1 Notes about the new version, migration and what it doesn't do - The issue might be resolved in that version, let me know what you think

hellkaim commented 6 years ago

@SinAndTonic I was looking for you regarding another topic. Please check my commit for details.

Sorry for inflating here.