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

Be able to update only one record from a query

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

      > Since :update and :update_all are aliases of each other, every call of the form:

      > Model.where(...).update(:foo => :bar)

      > Will update multiple records. Is there a way to flag to just update one
      record? Something like :multi => false in the 10gen driver. Sometimes I
      just want to do Model.where(:_id => params[:id]).update(:foo => :bar)
      without having it thinking it's a multi update or needing to first call
      Model.find(params[:id]) and then model.update_attributes(:foo => :bar). The
      former cuts down on the total number of database calls.

            Assignee:
            durran Durran Jordan
            Reporter:
            jonhyman Jon Hyman
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: