Skip to content

Latest commit

 

History

History
334 lines (191 loc) · 7.64 KB

class.RelationsService.md

File metadata and controls

334 lines (191 loc) · 7.64 KB

directus-monorepo ( Readme | API )


directus-monorepo > RelationsService

Class: RelationsService

Constructors

constructor()

new RelationsService(options): RelationsService

Parameters

Parameter Type
options AbstractServiceOptions

Returns

RelationsService

Source

api/src/services/relations.ts:31

Properties

accountability

accountability: any

Source

api/src/services/relations.ts:25


helpers

helpers: object

Type declaration

helpers.date

date: DateHelperMySQL | DateHelperDefault | DateHelperSQLite | DateHelperOracle | DateHelperMSSQL

helpers.schema

schema: SchemaHelperMySQL | SchemaHelperDefault | SchemaHelperCockroachDb | SchemaHelperSQLite | SchemaHelperOracle | SchemaHelperMSSQL

helpers.sequence

sequence: AutoIncrementHelperDefault | AutoIncrementHelperPostgres

helpers.st

st: GeometryHelperMySQL | GeometryHelperPostgres | GeometryHelperSQLite | GeometryHelperOracle | GeometryHelperMSSQL | GeometryHelperRedshift

Source

api/src/services/relations.ts:29


knex

knex: Knex< any, any[] >

Source

api/src/services/relations.ts:22


permissionsService

permissionsService: PermissionsService

Source

api/src/services/relations.ts:23


relationsItemService

relationsItemService: ItemsService< RelationMeta >

Source

api/src/services/relations.ts:27


schema

schema: SchemaOverview

Source

api/src/services/relations.ts:26


schemaInspector

schemaInspector: SchemaInspector

Source

api/src/services/relations.ts:24


systemCache

systemCache: Keyv< any, Record< string, unknown > >

Source

api/src/services/relations.ts:28

Accessors

hasReadAccess

private get hasReadAccess(): boolean

Source

api/src/services/relations.ts:451

Methods

alterType()

private alterType(table, relation): void

MySQL Specific

MySQL doesn't accept FKs from int to int unsigned. knex defaults .increments() to unsigned, but defaults regular int to int. This means that created m2o fields have the wrong type. This step will force the m2o int field into unsigned, but only if both types are integers, and only if we go from int to int unsigned.

TODO

This is a bit of a hack, and might be better of abstracted elsewhere

Parameters

Parameter Type
table TableBuilder
relation Relation

Returns

void

Source

api/src/services/relations.ts:569


createOne()

createOne(relation, opts?): Promise< void >

Create a new relationship / foreign key constraint

Parameters

Parameter Type
relation Relation
opts? MutationOptions

Returns

Promise< void >

Source

api/src/services/relations.ts:133


deleteOne()

deleteOne( collection, field, opts?): Promise< void >

Delete an existing relationship

Parameters

Parameter Type
collection string
field string
opts? MutationOptions

Returns

Promise< void >

Source

api/src/services/relations.ts:365


filterForbidden()

private filterForbidden(relations): Promise< Relation[] >

Loop over all relations and filter out the ones that contain collections/fields you don't have permissions to

Parameters

Parameter Type
relations Relation[]

Returns

Promise< Relation[] >

Source

api/src/services/relations.ts:504


readAll()

readAll(collection?, opts?): Promise< Relation[] >

Parameters

Parameter Type
collection? string
opts? QueryOptions

Returns

Promise< Relation[] >

Source

api/src/services/relations.ts:50


readOne()

readOne(collection, field): Promise< Relation >

Parameters

Parameter Type
collection string
field string

Returns

Promise< Relation >

Source

api/src/services/relations.ts:80


stitchRelations()

private stitchRelations(metaRows, schemaRows): Relation[]

Combine raw schema foreign key information with Directus relations meta rows to form final Relation objects

Parameters

Parameter Type
metaRows RelationMeta[]
schemaRows ForeignKey[]

Returns

Relation[]

Source

api/src/services/relations.ts:461


updateOne()

updateOne( collection, field, relation, opts?): Promise< void >

Update an existing foreign key constraint

Note: You can update anything under meta, but only the on_delete trigger under schema

Parameters

Parameter Type
collection string
field string
relation Relation
opts? MutationOptions

Returns

Promise< void >

Source

api/src/services/relations.ts:248


Generated using TypeDoc and typedoc-plugin-markdown