【发布时间】:2018-12-11 00:24:35
【问题描述】:
我正在使用 loopback 4 并尝试使用属性配置 Model 注释以配置如何在 Mongo 中创建集合。
我有一个模型叫做客户端,我希望 Mongo 中的集合被称为客户端。与文档的交叉令人困惑,因为它们在 v4 文档中引用了 v3 的属性。
我试过这个:
import {Entity, model, property} from '@loopback/repository';
@model({
settings: {strict: false},
name: 'client',
plural: 'clients',
options: {
mongodb: {
collection: 'clients',
},
},
})
export class Client extends Entity {
@property({
type: 'string',
id: true,
defaultFn: 'uuidv4',
index: true,
})
id: string;
@property({
type: 'string',
required: true,
})
name: string;
@property({
type: 'string',
})
code?: string;
constructor(data?: Partial<Client>) {
super(data);
}
}
没有Joy,仍然将集合创建为Class name Client
【问题讨论】:
标签: loopbackjs loopback v4l2loopback