N
N
Nwton2016-07-14 20:28:33
Node.js
Nwton, 2016-07-14 20:28:33

How to save multiple documents in mongoose with one command?

Several documents need to be saved. What is the best way to do this?
1) Run a loop and save asynchronously? In this case, I don't like that I have to make many requests at the same time.
2) Save each document separately, but in turn? Again, many requests.
3) Or is there a way to initiate a lot of new Model{}, push them into an array and somehow send them to the database with one command?
What do you advise?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
napa3um, 2016-07-14
@Nwton

stackoverflow.com/questions/16726330/mongoose-mong...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question