refactor: convert IDs to uuid

This commit is contained in:
Ali BARIN
2022-03-03 21:42:16 +01:00
committed by Ömer Faruk Aydın
parent 0c183eeadd
commit 02af7948e5
17 changed files with 45 additions and 31 deletions

View File

@@ -1,5 +1,6 @@
import { Model, snakeCaseMappers } from 'objection';
import { AjvValidator, Model, snakeCaseMappers } from 'objection';
import type { QueryContext, ModelOptions, ColumnNameMappers } from 'objection';
import addFormats from 'ajv-formats';
class Base extends Model {
createdAt!: string;
@@ -9,6 +10,19 @@ class Base extends Model {
return snakeCaseMappers();
}
static createValidator() {
return new AjvValidator({
onCreateAjv: (ajv) => {
addFormats.default(ajv);
},
options: {
allErrors: true,
validateSchema: true,
ownProperties: true,
},
});
}
async $beforeInsert(queryContext: QueryContext): Promise<void> {
await super.$beforeInsert(queryContext);