How to find by nested property in mongoose
You can specify the object nesting in form of string.
System.findOne({ "nodes.main.Alpha": 23000 }, function(err, system) {
if (err) {
console.log(err);
} else {
console.log(system);
}
});
This should work, can't verify right now but I recall I was using it this way somewhere.
Let me know if it helped..
Change this
System.findOne({ nodes: { main: {Alpha: 23000}}}, function(err, system){
if(err){console.log(err);}
else{console.log(system);}
});
to
System.findOne({ 'nodes.main.Alpha': 23000}, function(err, system){
if(err){console.log(err);}
else{console.log(system);}
});
This will work