A problem was detected: not all of my collection documents contained a value of "b", and therefore I received an error:
db.alerts.find({$where:"this.a < this.b.c"})
error: {
"$err" : "TypeError: Cannot read property 'c' of undefined",
"code" : 16722
}
Fixed by changing my request to:
{"b.c":{$exists : true}, $where : "this.c < this.b.c"}
source
share