Uploaded image for project: 'Couchbase Documentation'
  1. Couchbase Documentation
  2. DOC-9236

Missing documentation of mutateIn upsert/insert options.

    XMLWordPrintable

Details

    • DOC-2021-Dec05-S24, DOC-2021-Dec19-S25, DOC-2021-Dec31-S26, DOC-2022-S1, DOC-2022-S2, DOC-2022-S3, DOC-2022-S4, DOC-2022-S5, DOC-2022-S8, DOC-2022-S9
    • 1

    Description

      https://forums.couchbase.com/t/subdoc-on-non-existing-document/19539 

      A user is trying to mutate fields in a doc that may/may not exist yet. This is the basic scenario:

      1. mutate fields (if doc exists then everything ok)
      2. if mutate failed then insert new doc with those fields

      We should document this as it seems a useful scenario for users.

      In the forum we can see that this has been suggested by Brett:

      bucket.mutateIn('mydoc', {upsert: true})
        .upsert('foo.bar', 10, {createParents: true})
        .upsert('foo.baz', 20, {createParents: true})
        .execute((err) => {
          // Completed!
        });

      Which seems to be what the user was looking for (also see the linked issue, seems API docs needed to be updated).

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              richard.smedley Richard Smedley
              maria.shodunke Maria Shodunke (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes

                  PagerDuty