MongoDB Query Based on ObjectId Reference Condition MongoDB Query Based on ObjectId Reference Condition mongoose mongoose

MongoDB Query Based on ObjectId Reference Condition


Simple coding:

var cats = 0;db.Zoo.find({zooName: 'San Diego'}).forEach(function(zooItem){   var id = zooItem._id;   cats += db.Cat.find({'zooId' : id}).count();});print(cats);