These are chat archives for Automattic/mongoose

16th
Nov 2015
Theo Sherry
@theosherry
Nov 16 2015 13:44
Is there an easy way to list the indexes of a collection in mongoose?
James Lee
@uptownhr
Nov 16 2015 19:11
@benatkin i think you'd have to use sub documents
Valeri Karpov
@vkarpov15
Nov 16 2015 20:26
@benatkin not at the moment, there's a github issue out there for this feature but not supported atm. Right now you'd have to use an array
@theosherry mongoose.connection.getIndexes(function(error, indexes) {});
errr rather MyModel.collection.getIndexes(function(error, indexes) {});
Israel Cruz
@dantaex
Nov 16 2015 21:14
Anyone here knows why Model.update doesnt work but Model.findOneAndUpdate does?
    Product.findOneAndUpdate( 
        { _id:{ $in :[req.params.product_id] } },
        { published: false },
         function(err,na){
             if(err) res.status(500).send();
             else res.send(na);
         }
    );
That one totally works
    Product.update( 
        { _id:{ $in :[req.params.product_id] } },
        { published: false },
         function(err,na){
             if(err) res.status(500).send();
             else res.send(na);
         }
    );
Last one fails
I'm loosing my mind
Valeri Karpov
@vkarpov15
Nov 16 2015 23:56
how do you define 'fails' and "doesn't work"? Nothing looks immediately wrong in the examples you provided...