Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Запрос
- db.clients_data_info.aggregate( [
- { "$lookup" : { "from" : "inn2markets" , "localField" : "inn" , "foreignField" : "inn" , "as" : "inn2markets"}} ,
- { "$lookup" : { "from" : "markets" , "localField" : "inn2markets.marketId" , "foreignField" : "_id" , "as" : "market"}} ,
- { "$lookup" : { "from" : "products_dict" , "localField" : "dictId" , "foreignField" : "_id" , "as" : "dict"}} ,
- { "$replaceRoot" : { "newRoot" : { "$mergeObjects" : [ { "$arrayElemAt" : [ "$dict" , 0]} , "$$ROOT"]}}} ,
- { "$project" : { "dict" : 0}} ,
- { "$match" : { "date" : { "$lt" : { "$date" : "2018-06-23T21:00:00.000Z"}}}} ,
- { "$match" : { "date" : { "$gt" : { "$date" : "2018-06-22T21:00:00.000Z"}}}} ,
- { "$group" : { "_id" : "$clientId" , "clientDataInfos" : { "$push" : "$$ROOT"}}} ,
- { "$lookup" : { "from" : "clients" , "localField" : "_id" , "foreignField" : "_id" , "as" : "client"}} ,
- { "$skip" : 0} , { "$limit" : 50}]
- )
- clients_data_info
- {
- "_id" : ObjectId("5b2cdfc18c76fc1038457d9f"),
- "_class" : "io.ambuy.connect.orm.data.ClientDataInfo",
- "type" : "SHOPPINGLIST",
- "dictId" : ObjectId("5b2a247527e41ca6e2c436ab"),
- "count" : "22.05",
- "sum" : NumberLong(99997),
- "city" : "Москва",
- "src" : "0xcd2c0b1742c53b5f0fb53e06143110e98745cd9f",
- "date" : ISODate("2018-05-23T19:20:00.000Z"),
- "inn" : "7701285928",
- "clientId" : ObjectId("5b29617427e423187bf7819c")
- }
- inn2markets
- {
- "_id" : ObjectId("5b2cdfc18c76fc1038457d9e"),
- "_class" : "io.ambuy.connect.orm.data.Inn2MarketExpandable",
- "market" : {
- "_id" : ObjectId("5b2cde2e8c76fc1038d92a47"),
- "name" : "lukoil",
- "icon" : "a89c0fd8-77af-4653-9117-8510b81049af.png"
- },
- "inn" : "7701285928",
- "originalName" : "ООО \"ЛУКОЙЛ-Центрнефтепродукт\"",
- "marketId" : ObjectId("5b2cde2e8c76fc1038d92a47")
- }
- market
- {
- "_id" : ObjectId("5b2cdbf18c76fc1038e3851b"),
- "_class" : "io.ambuy.connect.orm.data.Market",
- "name" : "hello",
- "icon" : "d55459b9-3254-4378-852c-51796c03aaee.png"
- }
- products_dict
- {
- "_id" : ObjectId("5b2d2ee68c76fc49fc5807f1"),
- "_class" : "io.ambuy.connect.orm.data.ProductDict",
- "strId" : "5b2d2ee68c76fc49fc5807f1",
- "name" : "Бананы 1кг",
- "status" : "NOT_CONFIRMED"
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement