如果不指定任何内容,则在使用postgres时,所有字段都将在数据库中创建为小写字母。是否可以更改默认行为以使用模型中字段的确切名称?这样可以更轻松地编写自定义查询。
现在,我必须在每个字段上配置属性以说它们应该是驼峰式的,并且这很容易出错,因为这很容易忘记。
如果不可能,是否可以使用存储库中的功能,以某种简单的方式将所有小写字母映射到模型中的字段?
不确定是否有帮助,但是您可以使用name属性例如:
export class User extends .... { @property({
type: 'number',
id: true, }) id?: number;
@property({
type: 'string',
required: true,
name: 'first_name',
})
firstName: string;
@property({
type: 'string',
name: 'last_name',
})
lastName: string;