Insert/Update MiniMongo with methods rather than subscribe?

Working on optimizing some areas of my app with methods rather than pub/sub, and I’m hoping to minimize the required changes as much as possible because our app is quite large.

I know I’ll have to code in where to do the updates through methods and so on. My main problem is knowing how to actually insert/update in to MiniMongo itself on the client side, once I’ve received the data from the server.

I wasn’t able to find anything referenced in the documentation about how to insert/update in to MiniMongo outside of subscribing. Anyone have any links or advice to instruct how to do this?

I haven’t used this, yet but seems like this is what you need

The least complicated way to do this would be to fetch in a method and render, then when you update the data just fetch again. I know you’re app is large and you have reservations about large changes, but switching to cultofcoders:grapher is a really nice way to achieve your end goal, with the ability to switch between pub/sub and methods quite easily.

1 Like

I attempted to use pub-sub-lite, but it seems to not be compatible with kurounin:pagination. It just freezes if both of them are loaded.

I had posted an issue on github for both projects, and no response. Not sure how to repair the conflict between the two.

Grapher functionality does seem pretty nice, but without yet wrapping my head around it, it seems mostly based around queries. How would that switch between pub/sub and methods?

Is there no way to have a method update MiniMongo? As that would be easiest for this current project, as the interface is already configured around MiniMongo.

With grapher yes, you use grapher queries. They use either methods or pub/sub under the hood depending on whether they are reactive or non reactive queries. Switching is a matter of calling the fetchSync() method of the query rather than it’s fetch() method.

As far as having a method update minimongo… I think the easiest course here, if you found it necessary to store the docs in minimong, would be to create a client side, unmanaged collection that you could insert the documents into.


You can work with minimongo without using subscription.
You can define local collection:

const MyLocalCol = new Mongo.Collection('my_local_col', { connection: null });

Then you can work with that collection as normal: find, fineOne, insert, upsert…

The data will be there until you refresh browser so you may want to remove them manually.