I am developing a REST API using ArangoDB and Foxx. A pattern that keeps coming back in multiple models is the following:
const NewAccount = Foxx.Model.extend({
schema: {
name: Joi.string().required(),
... multiple properties
}});
When I store the model in the database, I want to add properties like the creation timestamp, the status of the account, ... .
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()
}});
question: Is there a way to let the Account model inherit all properties from the NewAccount model, so I only have to define the created and status properties?
Secondly, is there an efficient and easy way to copy all properties from a NewAccount instance into an Account instance ?