WIP - using objection base model to handle objects operations

This commit is contained in:
Francisco Gaona
2025-12-24 20:18:43 +01:00
parent e4f1ba96ad
commit 4520f94b69
15 changed files with 2325 additions and 16 deletions

View File

@@ -0,0 +1,35 @@
import { Model } from 'objection';
/**
* Base model for all dynamic and system models
* Provides common functionality for all objects
*/
export class BaseModel extends Model {
// Common fields
id?: string;
tenantId?: string;
ownerId?: string;
name?: string;
created_at?: Date;
updated_at?: Date;
// Hook to set system-managed fields
$beforeInsert() {
// created_at and updated_at are handled by the database
// ownerId should be set by the controller/service
}
$beforeUpdate() {
// updated_at is handled by the database
}
/**
* Get the API name for this object
* Override in subclasses
*/
static get objectApiName(): string {
return 'BaseModel';
}
}