-1

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.

Timofey Stolbov
  • 4,501
  • 3
  • 40
  • 45
Sam
  • 1,381
  • 4
  • 30
  • 70

2 Answers2

0

Try using the datalength property

eg

@property({ type: 'string', required: true, datalength:1000 }) description: string;

Steve
  • 1
  • 3
0

@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