directus-monorepo ( Readme | API )
directus-monorepo > RelationsService
new RelationsService(
options
):RelationsService
Parameter | Type |
---|---|
options |
AbstractServiceOptions |
api/src/services/relations.ts:31
accountability:
any
api/src/services/relations.ts:25
helpers:
object
date:
DateHelperMySQL
|DateHelperDefault
|DateHelperSQLite
|DateHelperOracle
|DateHelperMSSQL
schema:
SchemaHelperMySQL
|SchemaHelperDefault
|SchemaHelperCockroachDb
|SchemaHelperSQLite
|SchemaHelperOracle
|SchemaHelperMSSQL
sequence:
AutoIncrementHelperDefault
|AutoIncrementHelperPostgres
st:
GeometryHelperMySQL
|GeometryHelperPostgres
|GeometryHelperSQLite
|GeometryHelperOracle
|GeometryHelperMSSQL
|GeometryHelperRedshift
api/src/services/relations.ts:29
knex:
Knex
<any
,any
[] >
api/src/services/relations.ts:22
permissionsService:
PermissionsService
api/src/services/relations.ts:23
relationsItemService:
ItemsService
<RelationMeta
>
api/src/services/relations.ts:27
schema:
SchemaOverview
api/src/services/relations.ts:26
schemaInspector:
SchemaInspector
api/src/services/relations.ts:24
systemCache:
Keyv
<any
,Record
<string
,unknown
> >
api/src/services/relations.ts:28
private
get
hasReadAccess():boolean
api/src/services/relations.ts:451
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
.
This is a bit of a hack, and might be better of abstracted elsewhere
Parameter | Type |
---|---|
table |
TableBuilder |
relation |
Relation |
void
api/src/services/relations.ts:569
createOne(
relation
,opts
?):Promise
<void
>
Create a new relationship / foreign key constraint
Parameter | Type |
---|---|
relation |
Relation |
opts ? |
MutationOptions |
Promise
< void
>
api/src/services/relations.ts:133
deleteOne(
collection
,field
,opts
?):Promise
<void
>
Delete an existing relationship
Parameter | Type |
---|---|
collection |
string |
field |
string |
opts ? |
MutationOptions |
Promise
< void
>
api/src/services/relations.ts:365
private
filterForbidden(relations
):Promise
<Relation
[] >
Loop over all relations and filter out the ones that contain collections/fields you don't have permissions to
Parameter | Type |
---|---|
relations |
Relation [] |
Promise
< Relation
[] >
api/src/services/relations.ts:504
readAll(
collection
?,opts
?):Promise
<Relation
[] >
Parameter | Type |
---|---|
collection ? |
string |
opts ? |
QueryOptions |
Promise
< Relation
[] >
api/src/services/relations.ts:50
readOne(
collection
,field
):Promise
<Relation
>
Parameter | Type |
---|---|
collection |
string |
field |
string |
Promise
< Relation
>
api/src/services/relations.ts:80
private
stitchRelations(metaRows
,schemaRows
):Relation
[]
Combine raw schema foreign key information with Directus relations meta rows to form final Relation objects
Parameter | Type |
---|---|
metaRows |
RelationMeta [] |
schemaRows |
ForeignKey [] |
Relation
[]
api/src/services/relations.ts:461
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
Parameter | Type |
---|---|
collection |
string |
field |
string |
relation |
Relation |
opts ? |
MutationOptions |
Promise
< void
>
api/src/services/relations.ts:248
Generated using TypeDoc and typedoc-plugin-markdown