Skip to content
On this page

This is an auto-generated document to support extension builders understand the internal packages they can utilize. To find our written guides, tutorials, and API/SDK reference, check out our main docs .

Directus / @directus/sdk / rest / readRelation

Function: readRelation()

readRelation<Schema, TQuery>(collection, field): RestCommand<IfAny<Schema, Record<string, any>, Merge<MappedFunctionFields<Schema, UnpackList<TQuery>> extends FF ? MapFlatFields<UnpackList<TQuery>, keyof UnpackList<TQuery>, FF extends Record<string, string> ? FF : Record<string, string>> : never, Object>>, Schema>

List an existing Relation by primary key.

Type parameters

Schema extends object

TQuery extends Query<Schema, DirectusRelation<Schema>>

Parameters

collection: string

The collection

field: string

The field

Returns

RestCommand<IfAny<Schema, Record<string, any>, Merge<MappedFunctionFields<Schema, UnpackList<TQuery>> extends FF ? MapFlatFields<UnpackList<TQuery>, keyof UnpackList<TQuery>, FF extends Record<string, string> ? FF : Record<string, string>> : never, Object>>, Schema>

Returns a Relation object if a valid primary key was provided.

Throws

Will throw if collection is empty

Throws

Will throw if field is empty

Source

rest/commands/read/relations.ts:47