Click here to Skip to main content
15,904,288 members

Comments by YustasDev13 (Top 7 by date)

YustasDev13 13-Sep-21 10:50am View    
I have already posted this question on the forum, but so far no one has answered it
YustasDev13 13-Sep-21 10:32am View    
db.stores.aggregate([ { $unwind: "$listProducts" }, { $match : { "listProducts.productPrice" : { $ne : 0 } } }, { $group : { _id : { storeName : "$storeName", }, MAX_Products : { $max : "$listProducts.productPrice" } } } ])

this query works fine in MongoDB shell
YustasDev13 13-Sep-21 10:30am View    
No-no)
we know how to write a request to the MongoDB shell, but we do not know how to do it in Jongo...
that's the question!
YustasDev13 13-Sep-21 8:38am View    
thanks
and I could not find examples of using $unwind in Jongo...
YustasDev13 13-Sep-21 6:03am View    
Good day!
4.2.0
below is the structure of my collection
e332351f3f07(mongod-4.2.0) mongoStores> db.stores.find().pretty()
{
"_id": ObjectId("613a25870e945f654c1c2c5f"),
"storeName": "Пятерочка",
"listProducts": [
{
"_id": ObjectId("613a25e10e945f654c1c2c6e"),
"productName": "Молоко",
"productPrice": 55
},
{
"_id": ObjectId("613b12710e945f654c1c2f3f"),
"productName": "Кофе",
"productPrice": 200
}
]
}
{
"_id": ObjectId("613a25bf0e945f654c1c2c67"),
"storeName": "Копейка",
"listProducts": [
{
"_id": ObjectId("613a25cc0e945f654c1c2c6a"),
"productName": "Вода",
"productPrice": 10
},
{
"_id": ObjectId("613b12660e945f654c1c2f3c"),
"productName": "Чай",
"productPrice": 100
}
]
}
Fetched 2 documents in 4ms
e332351f3f07(mongod-4.2.0) mongoStores>
e332351f3f07(mongod-4.2.0) mongoStores> db.version()
4.2.0
e332351f3f07(mongod-4.2.0) mongoStores>