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 / readRelationByCollection

Function: readRelationByCollection()

readRelationByCollection<Schema>(collection): RestCommand<IfAny<Schema, Record<string, any>, Merge<MappedFunctionFields<Schema, DirectusRelation<Schema>> extends FF ? MapFlatFields<DirectusRelation<Schema>, keyof DirectusRelation<Schema>, FF extends Record<string, string> ? FF : Record<string, string>> : never, Object>>, Schema>

List an existing Relation by primary key.

Type parameters

Schema extends object

Parameters

collection: string

The collection

Returns

RestCommand<IfAny<Schema, Record<string, any>, Merge<MappedFunctionFields<Schema, DirectusRelation<Schema>> extends FF ? MapFlatFields<DirectusRelation<Schema>, keyof DirectusRelation<Schema>, 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

Source

rest/commands/read/relations.ts:30