Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-2478

$unset on multiple fields

    • Type: Icon: Task Task
    • Resolution: Done
    • 3.1.0
    • Affects Version/s: None
    • Component/s: None
    • Labels:

      As per http://docs.mongodb.org/manual/reference/operators mongodb allows specification of multiple fields for

      $unset

      operator. Mongoid, however, seems to only allow a single field for this operation

      For example, the following code works as expected:

      Person.where(tag: 'some tag').unset('name')
      Person.where(tag: 'some tag').unset('age')

      `

      
      But the code below does not. Instead it fails without an error. 
      
      

      Ruby
      Person.where(tag: 'some tag').unset(['name', 'age'])

      
      UPDATE: The Moped version of the command works fine though:
      
      

      Ruby
      Person.collection.find(tag: 'some tag').update_all('$unset' =>

      { 'name' => 1, 'age' => 1 }

      )
      `

            Assignee:
            durran Durran Jordan
            Reporter:
            cblock cblock
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: