0

I have the below mgo code to get objects matching an array of IDs

pipeline := []bson.M{
        bson.M{"$match": bson.M{"gsm_id": bson.M{"$in": fixtureIDs }}},
  }

But, I would like to return an array of the form below where missing fixtureIDs are just empty objects:

[ {'gsm_id': 1223456, 
   'data': { ... obj ...}
  },
  {'gsm_id': 1234558,
   'data': {}}
]
Neil Lunn
  • 148,042
  • 36
  • 346
  • 317
user1387717
  • 1,039
  • 1
  • 13
  • 30
  • This is just a regular query - why is it an aggregation? If it's part of a longer pipeline, what's the pipeline and what's it trying to do? You cannot produce documents from nothing in the aggregation pipeline, so you won't be able to get empty docs from a lack of a matching doc, but perhaps there's another way to achieve the greater objective lurking behind the scenes. – wdberkeley Nov 18 '14 at 19:57
  • Sorry you're right: not an aggregation - it's just a query, but I still don't know how to make it return data: {} for gsm_id's that aren't in the collection – user1387717 Nov 18 '14 at 20:00

0 Answers0