Skip to content

replace() doesn't need .get() #62

Closed

Description

@neumino

Right now to update a document, we have to do something like

r.db("foo").table("bar").get("id_value").replace({id: "id_value", ... }).run()

Since we can update one document and that the primary key is required in the argument of replace(), the query should just be:

r.db("foo").table("bar").replace({id: "id_value", ... }).run()

Tagging as backlog.

Activity

  1. coffeemug commented on Nov 15, 2012

    @coffeemug
    Contributor

    Ok, so we can't quite do it this way. The reason is that table.replace can accept a lambda/reql expression, which allows changing the documents across multiple rows.

    However, what we can do is allow people to call replace without specifying pkey inside the document in replace. We'd have to change the server to do it, and since this is a somewhat low priority issue, it'll take a little bit of time to get to it.

  2. mlucy commented on Nov 16, 2012

    @mlucy
    Member

    It looks like you want to do an upsert:

    r.table('bar').insert({:id => "id_value", ...}, :upsert).run
  3. coffeemug commented on Mar 18, 2013

    @coffeemug
    Contributor

    There isn't much we can do here. Closing.

  4. added a commit that references this issue on Jul 29, 2026
  5. added a commit that references this issue on Aug 7, 2026
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

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions