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

upsertAndFetch method for documents that are inserted if not found

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Won't Fix
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Querying
    • Labels:
      None
    • Case:

      Description

      Currently if one needs to insert a document only once for a particular "primary" value then they need to do something like:

      db.coll1.findOneAndUpdate({"item":"abc1"},{$setOnInsert:{"item":"abc1","xyz":123}},{upsert:true,returnNewDocument:true})
      

      The above returns the document if it exists already. If not, then it inserts that document. Instead of this can we have a API/method for upsertAndFetch().

        Attachments

          Activity

            People

            Assignee:
            backlog-server-query Backlog - Query Team (Inactive)
            Reporter:
            samaresh.singh Samaresh Singh
            Participants:
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: