How can I execute a callback after a massive multiple insert with Mongoose?
I have an object 开发者_运维问答results
that's very large (maybe over 1,000 items). I'm iterating over it to save to the DB but this seems very inefficient:
for result in results
item = new Item result
item.save()
Is there a more optimal way to do this and THEN get a callback as opposed to a callback for EVERY save?
The async module will help a lot with this. You're probably looking for a queue.
https://github.com/caolan/async#queue
You may be getting near the edge of a the normal Node.js use case.
精彩评论