refactor: convert IDs to uuid
This commit is contained in:

committed by
Ömer Faruk Aydın

parent
0c183eeadd
commit
02af7948e5
@@ -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);
|
||||
|
||||
|
Reference in New Issue
Block a user