0

if $props does not exists it should return blank array instead null value how can we fix it

db.collection.aggregate([
  {
    "$group": {
      "_id": "$prop3"
    }
  }
])

https://mongoplayground.net/p/3XGkbBKbtwW

John
  • 3
  • 2
  • Can you please [edit] your question to include the input documents and the expected output? – chridam Apr 14 '22 at 13:31
  • please check the fiddle $prop3 does not have value it should return [] insread [ { "_id": null } ] – John Apr 14 '22 at 13:40
  • From the marked answer in the duplicate `db.collection.aggregate([{$match:{prop3:{$exists:true,$ne:null}}},{$group:{_id:'$prop3'}}])` [Mongo Playground](https://mongoplayground.net/p/X5xX0VqONq3) – chridam Apr 14 '22 at 13:45

0 Answers0