upsertAndFetch method for documents that are inserted if not found

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Won't Fix
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Querying
    • None
    • Query
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None

      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().

            Assignee:
            Backlog - Query Team (Inactive)
            Reporter:
            Samaresh Singh (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: