These are chat archives for Automattic/mongoose

17th
Oct 2016
Mour
@mylamour
Oct 17 2016 04:35 UTC
jobinfo = function(info,cb){
remove : this.remove(Info).exec(cb)
}

how to judge whether if it sucessed ?

when i use

app.post('api/v1/removeJobinfo',test.removeJobinfo)

test.removeJobinfo = function(req,res){
      jobinfo.remove(info,function(err,data){
               if (err) throw err;
               if (???????){           // what should i do here???
                             res.json({sucess:true,info:"Sucessed ,and somthing .."});
}
});
};
Paul "Joey" Clark
@joeytwiddle
Oct 17 2016 10:12 UTC

The Mongoose docs for remove() point to Mongo docs, hinting that you will get a WriteResult back @mylamour.

You can check if data.nRemoved > 0 or something like that.

Mour
@mylamour
Oct 17 2016 11:19 UTC
thank u very much , i already try dat.nRemoved !=0 , but here still some problems ? i console.log(data), i didn't find nRemoved.but In mongo shell , it will return @joeytwiddle
Mour
@mylamour
Oct 17 2016 11:49 UTC
@joeytwiddle we can use data.result.ok == 1 && data.result.n == 0 , and it will be ok .
Ankur sharma
@ankur1163
Oct 17 2016 18:18 UTC
can someone help me? I am trying to use mlab.com in my app and my app crashes all the time
LeonineKing1199
@LeonineKing1199
Oct 17 2016 22:36 UTC
I know I've kind of had this discussion here before, but which is "slower" or "faster", an update query performed using $in: large_array or large_array.size separate update calls?
I'm restructuring some code and I want to go with the many individual updates vs just one massive update call
I'm assuming Mongo's thread-pooled so everything will just be queued and processed as it comes