首页 > 解决方案 > 如何在环回 4 中设置浮点类型

问题描述

我在环回 4 中使用以下代码来获得数字(浮点数)字段,但我的数据库中没有浮点数:

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

我正在使用MySQL数据库和环回迁移int(11)类型(文档只有number

有什么建议么?

标签: typescriptloopbackloopback4

解决方案


您可以将dataType用作:

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

推荐阅读