How to make synchronous call with mongoose and nodejs How to make synchronous call with mongoose and nodejs mongoose mongoose

How to make synchronous call with mongoose and nodejs


As stated in the comments you could use the npm async module.

Alternatively, you may prefer to nest callbacks (but this might lead to what is known as callback hell, viz many nested callbacks) or take advantage of the mongoose .then() method - see http://mongoosejs.com/docs/promises.html

Here you can do ..

EventModel.remove(args).then((removeResponse) => {  return EventModel.findOne(args);}).then((findResponse) => {  // etc})

These requests will happen synchronously.