typescriptloopbackloopback4

How to set float type in loopback 4


I am using following code in loopback 4 to have number (float) field, but I am not getting float in my DB:

@property({
  type: 'number',
  jsonSchema: {
    format: 'float',
  },
})
Field: number;

I am using MySQL database and loopback migrate with int(11) type (docs just have number)

Any Suggestions?


Solution

  • You can use dataType as:

    @property({
      type: 'number',
      dataType: 'FLOAT'
    })
    Field: number;