Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-19175

add support for $pull with $not

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 3.0.4
    • Component/s: Write Ops
    • None
    • Query
    • ALL
    • None
    • 0
    • None
    • None
    • None
    • None
    • None
    • None

      > db.version();
      3.0.4
      

      Example document:

      {
        _id: "...",
        foo: {
          bar: [ 1, null, 3, 4 ],
          baz: [ { value: 1 }, { value: null }, { value: 3 }, { value: 4 } ]
        }
      }
      

      I want to remove all values that are $lt: 4 or null. To simplify thing I wanted to use $not: { $gte: 4 }.

      This works:

      update(
        {},
        { $pull: { 'foo.baz': { 'value': {$not: { $gte: 4 } } } } }
      )
      

      And this does not work:

      update(
        {},
        { $pull: { 'foo.bar': { $not: { $gte: 4 } } } }
      )
      

      It gives the following error:

      "writeError" : {
      	"code" : 2,
      	"errmsg" : "unknown top level operator: $not"
      }
      

      Am I doing something wrong or is there another way to do this?

            Assignee:
            backlog-server-query Backlog - Query Team (Inactive)
            Reporter:
            benneq Benjamin M
            Votes:
            1 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: