Mongoose: Find() return document with the the object that contains the value

I found a way to return the data as I wish, by using aggregate with $unwind.

        $unwind: '$states'
        $unwind: '$states.cities'
        $match: {
            '': {$regex: city, $options: "i"}

        function (error, data) {
            return res.json(data);

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top