Page Contents

Home > @loopback/repository > ModelDefinition

ModelDefinition class

Definition for a model


export declare class ModelDefinition 


Constructor Modifiers Description
(constructor)(nameOrDef)   Constructs a new instance of the ModelDefinition class


Property Modifiers Type Description
name readonly string  
properties   { [name: string]: PropertyDefinition; }  
relations   RelationDefinitionMap  
settings   ModelSettings  


Method Modifiers Description
addProperty(name, definitionOrType)   Add a property
addRelation(definition)   Define a new relation.
addSetting(name, value)   Add a setting
belongsTo(name, definition)   Define a new belongsTo relation.
hasMany(name, definition)   Define a new hasMany relation.
hasOne(name, definition)   Define a new hasOne relation.
idProperties()   Get an array of names of ID properties, which are specified in the model settings or properties with id attribute.
referencesMany(name, definition)   Define a new referencesMany relation.