Tuesday 16 May 2017

Mongoose find inside schema collection array

I am trying to find the documents which has match inside it's array..

Schema name is food, and here is it

var foodSchema = {
    "store_id": String,
    'food': [{
        'dish': String
    }]
};
var store = mongoose.model('store', storeSchema);
module.exports = { store: store, food: food }

And here is the controller

dbModel.food.find({ 'food.dish': req.body.data }, function(err, foundUsers) {
        res.status(200).json({
            "success": "1",
            "message": foundUsers
        });
    });

It's returning empty always, how can i find it ?



via SA__

No comments:

Post a Comment