'loopback4 change the model datatype
I have a loopback4 model where am defining the property with type, required and it is connected with mysql database.Now for the description column i have defined as string and in the table it shows varchar(512). For the description i have more than 512 length. How to change this. If i change the length manually in the table. if i run it is getting changed to default. How to do this.
Model Code:
@property({
type: 'string',
required: true,
})
description: string;
I have changed the type to "text" but it is throwing error.Help me to solve this issue.
Solution 1:[1]
Try using the datalength property
eg
@property({ type: 'string', required: true, datalength:1000 }) description: string;
Solution 2:[2]
@property({
type: 'string',
required: true,
['mssql']: {
"columnName": "description",
"dataType": "text",
"dataLength": null,
"dataPrecision": null,
"dataScale": null,
"nullable": "NO"
}
})
description: string;
This should work if you're using the mssql connector. Replace mssql connector with the connector you're currently using
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Steve |
| Solution 2 | Daniel Mukuna K. |
