SurrealDB icon

SurrealDB

Interaction with a SurrealDB database

Record → Upsert Record

AI-generated

Summary

Insert or update a record in SurrealDB with a specified Record ID and JSON data, optionally specifying table, namespace, database, and connection pooling settings.

Inputs

  • Table — SurrealDB table name, e.g., "person" or "product". Can be omitted if the Record ID includes the table prefix.
  • Record ID (required) — ID of the record to upsert, such as "person:john" or "product:abc123". Used to identify the record; if Table is empty, the table part will be extracted from this ID.
  • Data (JSON) (required) — JSON data to create or update the record with.
  • Options — Optional parameters to override namespace and database settings for this operation.
  • Connection Pooling — Optional settings for connection pooling to control max/min connections, timeouts, retries, and validation behaviors for better performance.

Output shape

a single record with the upserted data as returned from SurrealDB

The response includes the upserted record data. No pagination or batched results are involved. Errors are returned per item if any issues occur during execution.

Examples

Example 1: Upsert a person record with ID 'person:john' and JSON data containing name and age fields.

Table field left empty, Record ID set to 'person:john', Data (JSON) with {"name":"John","age":30}, no additional options.

Links

Discussion