'use strict'; const Joi = require('joi'); const { Model } = require('@hapipal/schwifty'); module.exports = class Movie extends Model { static get tableName() { return 'movie'; } static get joiSchema() { return Joi.object({ id: Joi.number().integer().greater(0), title: Joi.string().min(3).required().example('The Matrix').description('Title of the film'), description: Joi.string().min(3).required().example('A computer hacker learns from mysterious rebels about the true nature of his reality and his role in the war against its controllers.').description('Description of the film'), director: Joi.string().min(3).required().example('Lana Wachowski').description('Director of the film'), releaseDate: Joi.date().required().example('1999-03-31').description('Release date of the film'), created_at: Joi.date(), updated_at: Joi.date() }); } $beforeInsert(queryContext) { this.created_at = new Date(); this.created_at = this.updated_at; } $beforeUpdate(queryContext) { this.updated_at = new Date(); } }