i developing rest api using arangodb , foxx. pattern keeps coming in multiple models following:
const newaccount = foxx.model.extend({ schema: {     name: joi.string().required(),     ... multiple properties }});   when store model in database, want add properties creation timestamp, status of 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: there way let account model inherit properties newaccount model, have define created , status properties?
secondly, there efficient , easy way copy properties newaccount instance account instance ?
there's no direct support extending schemas via inheritance. schemas objects, can extend them other object, example using _.extend:
var _ = require('underscore'); var baseaccountschema = {   // ... }; var extendedaccountschema = _.extend({}, baseaccountschema, {   // ... }); var newaccount = foxx.model.extend({   schema: baseaccountschema }); var account = foxx.model.extend({   schema: extendedaccountschema });      
Comments
Post a Comment