Working with a local only MongoDB?

Hi,
In my app, I want to create case templates (it has nothing to do with Spacebars, it’s part of the logic of my application) but not recording them in a remote Mongo before the end of the process. I tested using the session and reactive var but the problem is that there is no id automatically assigned as with Mongo and I need to make some adjustments before recording in Mongo. Is there a way to work solely on a local Mongo database and later synchronize it with the remote database?
Thank you in advance for your help.

1 Like

If you defined a mongo collection like this

MyLocalCollection = new Mongo.Collection(null);

Then it will only exist on the client. You could then later get the document, remove it from the local collection, and then add it to your “real” collection.

may be not the solution you are looking for but take a look at

Thank you! This is actually the solution I was looking for. I had already found this after posting my message but I have not been able to use it in practical way : when I get the id of the document inserted into the base in a callback function, I need to store it in a session variable or a reactive-var to then be able to put it in a helper. Moreover, I need only one document so I find that not very suitable to use a whole collection. In conclusion, I returned to the use of a reactive-var.