Working with Xata Records

The records API allows you to create, query, update, and delete records in a table. It lives under the table resource, accessible under https://{your-workspace-slug}.xata.sh/db/{db_branch_name}/tables/{table_name}/.

In the examples throughout this guide, we assume the following schema:

{
  "formatVersion": "1.0",
  "tables": [
    {
      "name": "teams",
      "columns": [
        {
          "name": "name",
          "type": "string"
        },
        {
          "name": "owner",
          "type": "link",
          "link": {
            "table": "users"
          }
        }
      ]
    },
    {
      "name": "users",
      "columns": [
        {
          "name": "email",
          "type": "email"
        },
        {
          "name": "full_name",
          "type": "string"
        },
        {
          "name": "address",
          "type": "object",
          "columns": [
            {
              "name": "street",
              "type": "string"
            },
            {
              "name": "zipcode",
              "type": "int"
            }
          ]
        },
        {
          "name": "team",
          "type": "link",
          "link": {
            "table": "teams"
          }
        }
      ]
    }
  ]
}

To run the examples from this tutorial, you can either use an HTTP client like Postman, Insomnia, or even your brower's console with fetch. If you prefer to work with a Command Line Interface (CLI), we recommend curl or similar.

In either case, we recommend creating a database named tutorial and deploying the above schema first. If you prefer to use a Command Line Interface (CLI), see the CLI getting started guide for how to load the above schema by using xata deploy. To create the databases with the web UI, visit the Xata web app.

Next Steps

Let's get started with this guide by learning how to insert data into a database.


Last modified 1 mo1 day ago