Objection
@adminjs/objection
$ yarn add ajv-formatsimport addFormats from 'ajv-formats';
import { AjvValidator, Model } from 'objection';
export abstract class BaseModel extends Model {
createdAt: string;
updatedAt: string;
static createValidator(): AjvValidator {
return new AjvValidator({
onCreateAjv: (ajv) => {
addFormats(ajv);
},
options: {
allErrors: true,
validateSchema: false,
ownProperties: true,
},
});
}
$beforeInsert(): void {
this.createdAt = new Date().toISOString();
}
$beforeUpdate(): void {
this.updatedAt = new Date().toISOString();
}
}
Nest.js Support
Last updated
