Skip to content

replace and generated_keys #5752

Open
Open

Description

@brandonbloom

It would be nice if replace returned generated_keys, like insert does when inserts happen.

The use case here is to do something like "Atomically updating a document based on a condition" from the Cookbook. If a new record is created, I'd like to know that record's ID without having to do returnChanges: true and pick it out of the larger structure.

Activity

  1. danielmewes commented on May 9, 2016

    @danielmewes
    Member

    I think generated_keys wouldn't really fit into replace, because replace never "generates" a key. The keys must be given beforehand.
    It seems like "inserted keys" would be the right thing here?

    We have been planning to deprecate generated_keys completely in favor of adding a new return_keys option instead, see #3074 (comment) . The return_keys option would make a keys value appear in the write result, which would look similar to generated_keys, but would include the primary keys of all inserted documents.
    I think that might handle your use case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions