Page Contents
Home > @loopback/repository > ModelDefinition
ModelDefinition class
Definition for a model
Signature:
export declare class ModelDefinition
Constructors
| Constructor | Modifiers | Description |
|---|---|---|
| (constructor)(nameOrDef) | Constructs a new instance of the ModelDefinition class |
Properties
| Property | Modifiers | Type | Description |
|---|---|---|---|
| name | string | ||
| properties | { [name: string]: PropertyDefinition; } | ||
| relations | RelationDefinitionMap | ||
| settings | ModelSettings |
Methods
| 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. |