在环回中使用postgres时,我可以将驼峰大小写作为默认值吗?

问题描述 投票:0回答:1

如果不指定任何内容,则在使用postgres时,所有字段都将在数据库中创建为小写字母。是否可以更改默认行为以使用模型中字段的确切名称?这样可以更轻松地编写自定义查询。

现在,我必须在每个字段上配置属性以说它们应该是驼峰式的,并且这很容易出错,因为这很容易忘记。

如果不可能,是否可以使用存储库中的功能,以某种简单的方式将所有小写字母映射到模型中的字段?

loopbackjs loopback4
1个回答
0
投票

不确定是否有帮助,但是您可以使用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;
© www.soinside.com 2019 - 2024. All rights reserved.