Skip to main content

ModelGraph

@webda/compiler


Type Alias: ModelGraph

ModelGraph = object

Defined in: compiler/src/definition.ts:106

Defined relationship for one model

Properties​

ancestors?​

optional ancestors?: string[]

Defined in: compiler/src/definition.ts:110

Model names of the parent of the parent, etc...


behaviors?​

optional behaviors?: ModelGraphBehaviorDefinition[]

Defined in: compiler/src/definition.ts:202

Behavior attributes — properties whose type is a class marked with @Behavior(). The Behavior class is referenced by Identifier so that the Behavior's actions can be looked up in the top-level behaviors map of the module.


binaries?​

optional binaries?: ModelGraphBinaryDefinition[]

Defined in: compiler/src/definition.ts:195

Binaries attribute, in the model you can declare attributes as Binary, so users can upload binaries that will be linked to this object with some metadata


children?​

optional children?: string[]

Defined in: compiler/src/definition.ts:182

References to every model that declare this model as a parent


dependents?​

optional dependents?: ModelRelationDependent[]

Defined in: compiler/src/definition.ts:189

Reverse index: every relation targeting this model whose policy is not NONE

Computed at build time for the models of the same module. Contains relations are not listed: their owner applies them to the models it lists.


indexes?​

optional indexes?: object[]

Defined in: compiler/src/definition.ts:177

Attributes tagged @Index / @Unique: an index (unique with @Unique) in the relational stores. The attributes sharing a name (@Index <name>) form one composite index, in declaration order

attribute​

attribute: string

name?​

optional name?: string

unique?​

optional unique?: boolean


optional links?: ModelRelation[]

Defined in: compiler/src/definition.ts:123

This contains links to other models. These links are low cardinality as ids and their selected attributes are stored in the current model.


maps?​

optional maps?: object[]

Defined in: compiler/src/definition.ts:153

Maps are deduplication of data in your model They are managed automatically by a service like ModelMapper

They are useful in NoSQL environment like DynamoDB or Firebase

attribute​

attribute: string

Attribute in the model

cascadeDelete​

cascadeDelete: boolean

@CascadeDelete (or @OnDelete CASCADE): deleting this model deletes the mapped models, the ones whose targetLink targets it

model​

model: string

Target model

targetAttributes​

targetAttributes: string[]

Target model attributes to duplicate

targetLink: string


parent?​

optional parent?: Omit<ModelRelation, "type" | "ownership">

Defined in: compiler/src/definition.ts:116

If the model has a parent

onDelete is the policy applied to this model when the parent is deleted: CASCADE when omitted


optional polymorphicLinks?: object[]

Defined in: compiler/src/definition.ts:125

Polymorphic references; absent models means any registered target. No cascade is implied.

attribute​

attribute: string

models?​

optional models?: string[]


queries?​

optional queries?: object[]

Defined in: compiler/src/definition.ts:133

Target other models with a new query This is usually our foreign keys

This will generate queries for you: SELECT * FROM 'model' WHERE 'targetAttribute' = 'this[attribute]'

attribute​

attribute: string

Attribute in the model

model​

model: string

Targeted model

targetAttribute?​

optional targetAttribute?: string

Targeted model attribute