【发布时间】:2019-09-18 11:44:41
【问题描述】:
我正在尝试使用 Strongloop Loopback 4 框架从模型中自动创建表。
我遇到的问题是模型属性都是小写的,即使它们是用 camelCase 定义的。
用户模型示例
@model({ name: 'users', settings: { strict: false }, excludeBaseProperties: ['password'] })
export class User extends Entity {
@property({
type: 'number',
id: true,
required: true,
generated: true,
})
id: number;
@property({
type: 'string',
required: true,
})
firstName: string;
@property({
type: 'string',
required: true,
})
lastName: string;
@property({
type: 'string',
required: true,
index: {
unique: true,
},
})
email: string;
@property({
type: 'string',
required: true,
index: {
unique: true,
},
})
username: string;
@property({
type: 'string',
required: true,
})
password: string;
[prop: string]: any;
constructor(data?: Partial<User>) {
super(data);
}
}
db.datasource.json
{
"name": "db",
"connector": "postgresql",
"url": "postgres://postgres:postgres@localhost:5432/test_db",
"host": "localhost",
"port": 5432,
"user": "postgres",
"password": "postgres",
"database": "test_db"
}
现在我在 package.json 中使用名为 migrate 的脚本或使用 automigrate() 得到了相同的结果。如您所见,名字和姓氏被定义为名字和姓氏,但是迁移完成后,它们被创建为名字和姓氏。有谁知道可能是什么问题?
【问题讨论】: