if you have a field inside authors that's required, you could do
something like this:
> db.coll.find({"authors.123": {$exists: true}}).forEach(printjson)
{
"_id" : ObjectId("4ef1ebc81f740f970e77a88a"),
"title" : "t1",
"authors" : {
"123" : {
"name" : "John"
},
"456" : {
"name" : "John"
}
}
}
{
"_id" : ObjectId("4ef1ec68f009a53f701b9227"),
"title" : "t5",
"authors" : {
"123" : {
"name" : "John"
},
"456" : {
"name" : "John"
}
}
}
another possibility is that instead of assigning {} to authors, if you
explicitly assign null to it ,
you could then do the following:
db.coll.find({"authors":{$not:{$type:10}}}).forEach(printjson)
$type:10 means NULL
let me knows if this helps