Time-series collection not working with $where filter

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Unresolved
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Query Integration
    • ALL
    • Hide
      > 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
      } 
      Show
      > 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 }
    • QE 2024-01-22, QE 2024-02-05, QE 2024-02-19, QE 2024-03-04, QE 2024-03-18, QE 2024-04-01, QE 2024-04-15, QE 2024-04-29, QE 2024-05-13, QE 2024-05-27, QE 2024-06-10, QE 2024-06-24, QE 2024-07-08, QE 2024-07-22, QE 2024-08-05, QE 2024-08-19, QE 2024-09-02, QE 2024-09-16, QE 2024-09-30, QE 2024-10-14, QE 2024-10-28, QE 2024-11-11, QE 2024-11-25, QE 2024-12-09, QE 2024-12-23, QE 2025-01-06, QE 2025-01-20, QE 2025-02-03, QE 2025-02-17, QE 2025-03-03, QE 2025-03-17, QE 2025-03-31, QE 2025-04-14, QE 2025-04-28, QE 2025-05-12, QE 2025-05-26, QE 2025-06-09, QE 2025-06-23, QE 2025-07-07, QE 2025-07-21, QE 2025-08-04, QE 2025-08-18, QE 2025-09-01, QE 2025-09-15
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Search for todo after finishing the investigation.

            Assignee:
            Unassigned
            Reporter:
            Yuhong Zhang
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: