I need to have full offline capability for my cordova app. That means that I need all of my collections to be saved locally. I’ve installed ground:db like so (because v2 doesn’t allow for methodResume functions):
meteor add ground:db@0.3.5
And I’ve added the following lines of code to my app:
if( Meteor.isCordova ) {
// This represents all of my collections
Ground.Collection(Entries);
Ground.Collection(Forms);
Ground.Collection(Photos);
Ground.Collection(Projects);
}
Ground.Collection(Meteor.users);
if( Meteor.isClient ) {
Ground.methodResume([
'createEntry',
'updateEntry',
'removeEntry',
'createForm',
'updateForm',
'removeForm',
'createPhoto',
'updatePhoto',
'removePhoto',
'createProject',
'updateProject',
'removeProject',
'updateUserDetails'
]);
}
My problem is that the cordova app does not save the entire collection (some documents are missing when I go to offline mode). Do I need to subscribe all of the documents in all collections in every route (in online and offline modes)?
GroundDB only persists what is in the client side cache already, so if you indeed need every record, then yes you will need to subscribe to all documents. Depending on the # of documents in a collection, this could get pretty heavy on the client to the point of possibly filling your LocalStorage to it’s limit.
Unfortunately, it is suitable only for text storage.
By the way, it is a big drawback for Meteor which is a platform for developing modern web and mobile applications, not to provide a real solution for offline data on the mobile.
I don’t think this has much to do with Meteor and more to do with the constraints of the browser. You could always try react native and connect it to your meteor app.
You will have to handle all the synchronization between your data on your back-end and your client, but for caching it locally I highly recommend this version of GDB.
I need to be able to resume method calls. Simply caching data isn’t really what I consider offline capability. I need is to be able to create new documents.