SurrealDB icon

SurrealDB

Interaction with a SurrealDB database

Relationship → Query Relationships

AI-generated

Summary

Query relationships in SurrealDB filtering by optional record ID, relationship type, and direction, returning relationship data optionally including properties and filtering by target table.

Inputs

  • Record ID — ID of the record to query relationships for in format "table:id"; if empty, queries all relationships of the specified type.
  • Direction (required) — Direction of relationships to query: outgoing (from the record), incoming (to the record), or both.
  • Relationship Type — Type of relationship to filter by; leave empty to query all types.
  • Namespace — Optional namespace override for the operation.
  • Database — Optional database override for the operation.
  • Target Table — Filter relationships to those targeting a specified table.
  • Include Properties — Whether to include relationship properties in the query results; defaults to true.
  • Return Each Relationship As Item — Whether to return each relationship as a separate item or all as a single item with an array property; defaults to false.
  • Treat Missing Table As Empty Result — Return empty result instead of error when source table does not exist; useful for compatibility between SurrealDB versions.
  • Connection Pooling Options — Settings to configure connection pooling behavior for performance optimization, such as max connections, timeouts, and retries.

Output shape

a JSON array of relationship records or a single item containing an array, depending on 'Return Each Relationship As Item' option

Each relationship record includes relationship data and may include properties if enabled. Query respects optional filters. Errors may occur if tables do not exist unless 'Treat Missing Table As Empty Result' is enabled.

Links

Discussion