Offline meteor application using ground:db

Hello All,

I am working with offline support of Meteor Application. I have researched about this support but all are giving one answer ‘ground:db’. I looked into that solution its really nice effort by @raix. I started with that package, Its already working project so first task i have done that all collection i have grounded with following syntax

var Users = Meteor.users;
if(Meteor.isClient){
     SmtGroundCollections.Users = Ground.Collection(Users);
}

After that i have tried with my offline application but still its showing loading and i am not getting my dom elements after that i have tried with that all waitOn subscription i have put on condition

if(Meteor.status().connected){
        /* my subscriptions */
}

After that i am able to see my dom and if i visited that page when i am online then after i am going offline i am able to see my data.

Now i am explaining my problems.

  1. When i am calling my methods its not updating my ground collection if i am offline. I used below code for resume my methods
if(Meteor.isClient){

    Ground.methodResume([

        'addProfie',

        ' editProfile' ,

        ' deleteProfile ' ,
    ]);
}

Its working fine when i am coming from offline to online its syncing my data to server but i am not able to immediate effect.

  1. If i want full application offline then i need to visit every page of my mobile application and then i can get that data in offline but its not possible so i want one centralise thing where i will press button and i can grounded my all data which i want offline.

So can anyone help me to solve above problem

Thanks in advance

Could you show us the code of a method that does not update offline collection ?
Are you sure you call the simulation method on the client side?

Hello @vikti

below method i am calling to update or insert anything in offline collection.

addProfile : function(doc){
        check(doc, Object);
        var obj=({name:doc.name, email:doc.email , age : doc.age});
        return Profile.insert(obj);
    },

client side

Meteor.call('addProfile', insertDoc, function(error, result) {
                if (error) alert(error.reason);
            });

How do you ground this collection?

var Profile = Meteor.users;
if(Meteor.isClient){
     SmtGroundCollections.Profile = Ground.Collection(Profile);
}

It seems that your method inserts an object in MiniMongo Meteor.users (Profile.insert(obj);) which is not grounded.
What if your change return Profile.insert(obj); by return SmtGroundCollections.Profile.insert(obj); ?

Yes i will try. What about if i am online??

You can use a cursor to always sync online -> groundDB.
eg:

var cursor = Profile.find(); SmtGroundCollections.Profile.observeSource(cursor);

But that means you have to be sure, when back online, that offline new data is sent to the server BEFORE the server sends back the the data. If not, all you offline data will be erased with the data present on the server before the user disconnexion. Meteor method resume mechanism should handle that.

its giving error observeSource is not a function

Did you declare var = SmtGroundCollections.Profile = Ground.Collection(Profile); before ?

@raix

can you give me answer about my concern?