du kan bruge mongodb-aggregering til at få nøjagtigt output som krævet af
Account..aggregate([
{$match:{'buildings.gateways.devices.verificationCode':"4146"}},
{$unwind:"$buildings"},
{$unwind:"$buildings.gateways"},
{$unwind:"$buildings.gateways.devices"},
{$match:{'buildings.gateways.devices.verificationCode':"4146"}}
])