Directus / @directus/sdk / rest / readRelation
Function: readRelation() ​
readRelation<
Schema
,TQuery
>(collection
,field
):RestCommand
<IfAny
<Schema
,Record
<string
,any
>,Merge
<MappedFunctionFields
<Schema
,UnpackList
<TQuery
>> extendsFF
?MapFlatFields
<UnpackList
<TQuery
>, keyofUnpackList
<TQuery
>,FF
extendsRecord
<string
,string
> ?FF
<FF
> :Record
<string
,string
>> :never
,Object
>>,Schema
>
List an existing Relation by primary key.
Type parameters ​
• Schema
• 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
<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