I had searched other posts, but what seems to work fine just couldn't work here. I need your advice.
Here is what my document looks like in the database, just one document with a series of tag in it.
I need to just query, the restaurant type which has counter greater than 0, (so the end result will exclude any type with counter 0)
My schema
const tagsSchema = mongoose.Schema({
  _id: mongoose.Schema.Types.ObjectId,
  details: {
    restaurantTypeId: mongoose.Schema.Types.ObjectId,
    restaurantTypes: [{
      _id: mongoose.Schema.Types.ObjectId,
      name: String,
      counter: Number,
    }],
    foodTypeId: mongoose.Schema.Types.ObjectId,
    foodTypes: [{
      _id: mongoose.Schema.Types.ObjectId,
      name: String,
      counter: Number,
    }]
  }
});
I have tried
    tags.find({
    'details.restaurantTypes.counter': {
        $gt: 0
    }
}, (err, data) => {
    if (err) {
        res.send(err);
    }
    res.json(data);
});
and I got
[
{
    "details": {
        "restaurantTypeId": "5c01fb57497a896d50f49877",
        "restaurantTypes": [
            {
                "_id": "5c01fb57497a896d50f49879",
                "name": "Asian",
                "counter": 1
            },
            {
                "_id": "5c01fb57497a896d50f4987a",
                "name": "Bakery",
                "counter": 0
            },
            {
                "_id": "5c01fb57497a896d50f4987b",
                "name": "Barbecue",
                "counter": 0
            },
            {
                "_id": "5c01fb57497a896d50f4987c",
                "name": "Bars & Pubs",
                "counter": 0
            },
            {
                "_id": "5c01fb57497a896d50f4987d",
                "name": "Bistro",
                "counter": 0
            },
and
    tags.find({
    'details.restaurantTypes.counter': {
        $gte: 1
    }
}, (err, data) => {
    if (err) {
        res.send(err);
    }
    res.json(data);
});
which give me the same result

 
    