From 4298303ea4fef5c53aad9bf91bcae9a735c4e4c7 Mon Sep 17 00:00:00 2001 From: Rodrigo Rodriguez Date: Thu, 16 Jan 2025 05:29:53 -0300 Subject: [PATCH] new(kb.gblib): added postgres. --- packages/basic.gblib/services/GBVMService.ts | 28 +++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/packages/basic.gblib/services/GBVMService.ts b/packages/basic.gblib/services/GBVMService.ts index d2ce9e80..abef6728 100644 --- a/packages/basic.gblib/services/GBVMService.ts +++ b/packages/basic.gblib/services/GBVMService.ts @@ -289,19 +289,27 @@ export class GBVMService extends GBService { acquire: acquire }, define: { + // Disable timestamps globally + timestamps: false, + // Prevent createdAt/updatedAt from being selected + defaultScope: { + attributes: { + exclude: ['createdAt', 'updatedAt'] + } + }, // Convert all table names to lowercase freezeTableName: true, hooks: { beforeDefine: (attributes, options) => { - // Convert model name and table name to lowercase - if (options.modelName) { - options.modelName = options.modelName.toLowerCase(); - } - if (options.tableName) { - options.tableName = options.tableName.toLowerCase(); - } else { - options.tableName = options.modelName.toLowerCase(); - } for (const attr in attributes) { + // Convert model name and table name to lowercase + if (options.modelName) { + options.modelName = options.modelName.toLowerCase(); + } + if (options.tableName) { + options.tableName = options.tableName.toLowerCase(); + } else { + options.tableName = options.modelName.toLowerCase(); + } for (const attr in attributes) { const lowered = attr.toLowerCase(); if (attr !== lowered) { attributes[lowered] = attributes[attr]; @@ -427,7 +435,7 @@ export class GBVMService extends GBService { const shouldSync = min.core.getParam(min.instance, 'Synchronize Database', false); tableDef.forEach(async t => { - const tableName = t.name.trim().toLowerCase (); + const tableName = t.name.trim().toLowerCase(); // Determines autorelationship.