skip to Main Content

How to use $cond in mongoDB

Please refer the attached image and help me explain this case. Why didn't cova_items column assigned value of InStock column when woo_order_id is null? query command: db.cova_order.aggregate([ { $project:{ InStock:1, woo_order_id:1, woo_order_data:1, cova_items:{ $cond: { if: { $eq:["$woo_order_id",null] }, then:"$InStock"…

VIEW QUESTION

Using lookup with group in mongodb

I have a bunch of records in this format on mongodb [ {_id: 1, date:'2023-07-28',sales:1,ad_id:1,status: 'Active'}, {_id: 2 , date:'2023-07-29',sales:2,ad_id:1,status: 'Active'}, {_id: 3, date: '2023-07-30',sales: 4,ad_id:1,status: 'Paused'} ] Now if I want data from date 2023-07-28 to 2023-07-29 . I…

VIEW QUESTION
Back To Top
Search