Skip to content

Update a single record in an existing table #1863

@simonw

Description

@simonw

API design:

POST /db/table/row-pks/-/update
{
   "field": "updated_value"
}

Only the fields that you pass will be updated.

Maybe this is the wrong design though? The design for insert currently looks like this:

POST /db/table/-/insert
Authorization: Bearer xxx
Content-Type: application/json
{
  "row": {
    "id": 1,
    "name": "New name"
  }
}

I could use the same format for /-/update, but in this case the API doesn't require you to pass every field so "row" doesn't seem like the right key.

I think I'll go with this:

POST /db/table/1/-/update
Authorization: Bearer xxx
Content-Type: application/json
{
  "update": {
    "name": "New name"
  }
}

The benefit of having an "update" key is that it allows me to use other keys in the future. Maybe a "alter": true key to indicate that new columns should be added if they are missing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions