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

self referential updates? WAS: allow access to old row value during update

    • Type: Icon: New Feature New Feature
    • Resolution: Won't Do
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Write Ops
    • Labels:
      None
    • Query

      Right now, you can't access the old value of a row during an update. You have to decide what each field you want to update should look like on the client side. So you can't do:
      { $set : { "creation_timestamp" : coalesce(old.creation_timestamp, <now>) }}
      or:
      { $set : { "priority" : max(old.priority, 3) }}
      or:
      { $set : { "widgets_being_processed" : old.widgets_needing_processing }}

      ... or any equivalent.

      You can do this kind of thing with two queries, but that has potential performance and concurrency problems.

      From what I know of the Mongo architecture I don't see why access to this information should be impossible. I don't know what the syntax would be, of course.

      See also my original email question: http://groups.google.com/group/mongodb-user/browse_thread/thread/1c7b424cf9ef48e8/877621f662ca4cc0

            Votes:
            37 Vote for this issue
            Watchers:
            38 Start watching this issue

              Created:
              Updated:
              Resolved: