Following long the lines of Mongoose and Sequelize. It'd be worth having a Schema / Model that can be passed to the constructor which can be validated against when making any CRUD operations.
A good example of a validator to use would be https://github.com/epoberezkin/ajv. Which follow JSONSchema and allows for default fallbacks.
Following long the lines of Mongoose and Sequelize. It'd be worth having a Schema / Model that can be passed to the constructor which can be validated against when making any CRUD operations.
A good example of a validator to use would be https://github.com/epoberezkin/ajv. Which follow JSONSchema and allows for default fallbacks.