SurrealDB icon

SurrealDB

Interaction with a SurrealDB database

Relationship → Create Relationship

AI-generated

Summary

Create a relationship between two SurrealDB records by specifying their record IDs and optionally defining the relationship type and additional properties.

Inputs

  • From Record ID (required) — The ID of the record from which to create the relationship, formatted as "table:id" (e.g., person:john).
  • To Record ID (required) — The ID of the record to which to create the relationship, formatted as "table:id" (e.g., person:jane).
  • Relationship Type — The type or label of the relationship (e.g., knows, likes, wrote).
  • Properties — Optional key-value pairs representing additional properties to set on the created relationship.
  • Options — Optional settings including namespace and database overrides, return type preferences (e.g., return record after creation), and connection pooling configurations.

Output shape

a single record or an array containing the created relationship(s) depending on whether multiple inputs are processed; the output format and contents depend on the selected Return option (e.g., AFTER returns the record after changes) and the Only flag which returns a single object instead of an array with one object.

If the Only option is enabled, the output is a single object; otherwise, it is an array. The Return option controls whether the output includes the record after creation, before creation, the difference, or no output. The operation requires both From and To Record IDs and at least one of Relationship Type or the other IDs to proceed.

Links

Discussion