Я хочу написать статистическую функцию для выбора всех имен, имеющих TCS, в коллекции за один вызов -
Как мне написать, чтобы получить все имена с TCS за один вызов?
db.stocks.find()
{ "_id" : ObjectId("5d81e624ae6a505982c1c409"), "name" : "Infosys", "qty" : 100, "price" : 800 }
{ "_id" : ObjectId("5d81e624ae6a505982c1c40a"), "name" : "TCS", "qty" : 100, "price" : 2000 }
{ "_id" : ObjectId("5d81e624ae6a505982c1c40b"), "name" : "Wipro", "qty" : 2500, "price" : 300 }
{ "_id" : ObjectId("5dbea62c608aba164b7c869b"), "name" : "TCS", "qty" : 0, "price" : 800 }
{ "_id" : ObjectId("5dbea62c608aba164b7c869c"), "name" : "TCS", "qty" : 0, "price" : 2000 }
db.stocks1.find()
{ "_id" : ObjectId("5d81e652ae6a505982c1c40c"), "name" : "Infosys_1", "qty" : 100, "price" : 800 }
{ "_id" : ObjectId("5d81e652ae6a505982c1c40d"), "name" : "TCS_1", "qty" : 100, "price" : 2000 }
{ "_id" : ObjectId("5d81e652ae6a505982c1c40e"), "name" : "Wipro_1", "qty" : 2500, "price" : 300 }
{ "_id" : ObjectId("5d81f013ae6a505982c1c40f"), "name" : "Infosys", "qty" : 200, "price" : 800 }
{ "_id" : ObjectId("5d81f013ae6a505982c1c410"), "name" : "TCS", "qty" : 200, "price" : 2000 }
{ "_id" : ObjectId("5d81f013ae6a505982c1c411"), "name" : "Wipro", "qty" : 3500, "price" : 300 }
{ "_id" : ObjectId("5dbea5dd608aba164b7c8698"), "name" : "TCS", "qty" : 0, "price" : 800 }
{ "_id" : ObjectId("5dbea5dd608aba164b7c8699"), "name" : "TCS", "qty" : 0, "price" : 2000 }
{ "_id" : ObjectId("5dbea5dd608aba164b7c869a"), "name" : "TCS", "qty" : 4500, "price" : 300 }
db.stocks2.find()
{ "_id" : ObjectId("5d81f0ceae6a505982c1c412"), "name" : "Infosys", "qty" : 300, "price" : 800 }
{ "_id" : ObjectId("5d81f0ceae6a505982c1c413"), "name" : "TCS", "qty" : 300, "price" : 2000 }
{ "_id" : ObjectId("5d81f0ceae6a505982c1c414"), "name" : "Wipro", "qty" : 4500, "price" : 300 }