Minimongo and store

Minimongo store only in memory, and obviously the data disappear when the browser is refreshed.
I saw https://github.com/mWater/minimongo and it seems that Minimongo also supports other browser local databases, such IndexedDB, WebSQL.
I also saw that it is forked in 2014 for Meteor code.
I’m new in the Meteor’s world, and I cant’ understand if there is a reason to not implement this databases that could bring some improovement for offline use.
Surely there will be reasons, could help me to understand it ?

What would you like to do offline?

It’s hard to say everything that is possible to do offline, there is a world of apps can use in offline mode.
One simply examples: a small app (webapp) to take notes, perhaps used on a smartphone, so even in cases of no network I can still adding a note, or read a note, even if the browser was closed (and loose the data in memory), or if the app is a Cordova app, same data loss once it has been closed or removed from tasks.
I would like to understand why there are methods to keep data in local databases and why current Minimongo allows it and why meteor Minimongo doesn’t.
If it was chosen to do so there will be a reason, I did not understand this, maybe is to hard implement this ? Maybe is for structure of different db (no sql, no schema vs relational database of indexeddb).
I want to say that I have recently been in the meteor world, maybe they are obvious things, but honestly I do not understand them fully.
And, finally, thanks for your time @paulishca , you have help me many time, I remember when I implement push notifications in my first app… how long I worked on it but then everything went well !
(I have something to tell you about synchronism of offline data, I thought about it and I would like to let you know, in the right thread, so can be keep the flow)

Ok, I understand your point with offline but you see …
add a note: when you add a note, you don’t save each letter to the DB, you write in a ‘buffer’, most of the time in a local state. That is absolutely fine to put in a local DB on a mobile. However, Minimongo was designed for something different, it is a mirror of a batch of data from Mongo. Minimongo is almost Mongo.

Where the whole offline concept fails is when you want to offline-edit a note which is not on your phone. Or if you want to book a ticket offline, paginate some posts, etc. There are so many case that don’t work in any app not only Meteor.
Offline we can both generate documents like in a chat. I send you a message offline, you send me one, we have two messages that we both see sorted by date when we go online.
However, when we both have the same document and we both want to edit it offline… You come online first and write to server, I then come online but I have the version from before you saved and I overwrite your version unless I check whether my version is current or maybe your is current … etc.

What I am saying here with this story is that you can very well do a lot of offline, away from Minimongo, using Methods and writing to a local DB (I prefer RealmDB because it is … possibly the best mobile JS DB). It is not that you cannot and it is not that it can be built natively into Meteor (my opinion). This is subject to application design for each an every individual app.

1 Like

ok, I agree all but, my question “why Minimongo in Meteor don’t support indexeddb or websql like Minimongo officiale project ?” you have an idea ?
Is to difficult ? is not right to do because is not suitable for Meteor ?

1 Like

There’s a feature request for that from @simonsimcity and it answers your question:

One major downside I see so far is that many of the calls are asynchronous (based on callbacks) and could therefore only be introduced on the client if we would switch to a promise-based interface for database-calls.

Such a change would force virtually everyone to make a lot of changes to their projects.

1 Like

ok but in case of new project ?
So, it can be a “switch” to select what kind of storage you prefered to use in your app, or I’m wrong in understand it ?

Not really. If you’d decide that you’d like to use asynchronous storage, then every Meteor package (including core packages) has to use asynchronous API. In the end, it impacts a big part of the API surface.

Ok, that clear my doubts.
So, if I want to create a generic offline app, I have to manually implement it or use a packages for that, right ?
You know some package for this ?
I saw https://atmospherejs.com/ground/db or https://atmospherejs.com/stumps/persist-collection, you think I can start to learn it ?

I tested a few of these offline-minimongo packages in the past (at least 3 years back) and I think ground:db was the one that worked for us the most. It requires some work though, and debugging reconnections is not that easy and very time-consuming.

It depends on the app and the kind of offline experience you’d like to deliver, but maybe some custom offline persistency (with a backend of choice) and any source (either non-reactive using methods or reactive, using minimongo) would be the easiest to make and maintain.

Or try a few packages and let us know, which one worked for your case.

2 Likes