| Steps To Reproduce: |
> db.getCollection('system.js').insert({ _id: "isTeenager", value: function(age) { return age >= 13 && age <= 19; }, })
|
WriteResult({ "nInserted" : 1 })
|
> db.createCollection("ts", {timeseries: {timeField: "time"}})
|
{ "ok" : 1 }
|
> db.ts.insert({time: new Date(), name: 'Alice', age: 20})
|
WriteResult({ "nInserted" : 1 })
|
> db.runCommand({find: "ts", filter: {$where: "isTeenager(this.age)"}})
|
{
|
"ok" : 0,
|
"errmsg" : "$where is not allowed in this context",
|
"code" : 2,
|
"codeName" : "BadValue"
|
}
|
> db.foo.insert({name: 'Alice', age: 20})
|
WriteResult({ "nInserted" : 1 })
|
> db.runCommand({find: "foo", filter: {$where: "isTeenager(this.age)"}})
|
{
|
"cursor" : {
|
"firstBatch" : [ ],
|
"id" : NumberLong(0),
|
"ns" : "test.foo"
|
},
|
"ok" : 1
|
}
|
|