【发布时间】:2016-03-29 22:24:11
【问题描述】:
我正在使用 ArangoDB 和 Foxx 开发一个 REST API。在多个模型中不断出现的模式如下:
const NewAccount = Foxx.Model.extend({
schema: {
name: Joi.string().required(),
... multiple properties
}});
当我将模型存储在数据库中时,我想添加诸如创建时间戳、帐户状态等属性。
const Account = Foxx.Model.extend({
schema: {
name: Joi.string().required(),
... multiple properties,
created: Joi.number().integer().required().default(Date.now, 'Current date'),
status: Joi.number().integer().required()
}});
问题: 有没有办法让 Account 模型继承 NewAccount 模型的所有属性,所以我只需要定义 created 和 状态 属性?
其次,是否有一种有效且简单的方法可以将 NewAccount 实例中的所有属性复制到 Account 实例中?
【问题讨论】: