Template
single collection
multiple collections
mgodatagen
update
indexe
explain
Stage
Database
bson
mgodatagen
[{"key":1},{"key":2,author:"john"},{"key":3,authors:["john2","john3"]}]
Query
db.collection.aggregate({$project:{"authors":{"$ifNull":["$authors",[{$ifNull:["$author","oops"]}]]}}})
Result