Vitaly Gusev
unread,Sep 13, 2021, 8:42:19 AM9/13/21Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Jongo
I have a simple (working) query from unwind to MongoDB, how can I write this query using Jongo?
db.stores.aggregate([ { $unwind: "$listProducts" }, { $match : { "listProducts.productPrice" : { $ne : 0 } } }, { $group : { _id : { storeName : "$storeName", }, MAX_Products : { $max : "$listProducts.productPrice" } } } ])
What I have tried:
Aggregate.ResultsIterator max = stores.aggregate("{$unwind:{$listProducts}") .and("{$match:{ $ne : 0 }") .and("{$group:{$storeName}") .and("{$max:{$listProducts.productPrice}") .as(Store.class);
but I get
Exception in thread "main" java.lang.IllegalArgumentException: Cannot parse query: {$unwind:{$listProducts}