These are chat archives for Automattic/mongoose

22nd
Apr 2016
Gjorge Karakabakov
@gorgekara
Apr 22 2016 05:16
Hello guys - how can i make sure that all updates to a specific collection item have finished? I'm making an API and when i spam update (returns updated data), then send a GET with findOne it sometimes returns old data.
Code i use for update
User
        .findByIdAndUpdate({ _id: id }, { $set: params }, { 'new': true })
        .select('-password')
        .exec(function (error, user) {
          return res.json({ user: user });
        });
code i use for get
User
    .findById(id, '-password')
    .populate('...')
    .populate('...')
    .exec(function (error, user) {