Meteor Package Update

I use a meteorite. I am wondering if theres an abridged way of doing batch updates before updating the DOM.

For example, I want to update some records, more than one (all at once):

Collection.update(id1,{..}) Collection.update(id2,{..}) Collection.update(id3,{..}) 

The problem is that 3 items are updated separately. Therefore, when the DOM in my case was redrawn 3 times instead of once (with all 3 updated entries).

Is there any way to keep ui updated until all of them are updated?

+7
source share
2 answers

Run them on the server instead, so they can be synchronously executed so that they are less likely to trigger multiple DOM updates on the client.

See the first two and last interesting code codes that explain how to protect your clients from clutter with the database, as well as how to identify methods on the server and call them from the client.

-one
source

A Mongo update can modify more than one document at a time. Just give it a selector that matches more than one document and set the multi parameter. In your case, this is just a list of identifiers, but you can use any selector.

 Collection.update({_id: {$in: [id1, id2, id3]}}, {...}, {multi:true}); 

This will trigger a single database update and a single change.

+23
source

All Articles