new(kb.gblib): added postgres.
This commit is contained in:
parent
632010310b
commit
4298303ea4
1 changed files with 18 additions and 10 deletions
|
@ -289,19 +289,27 @@ export class GBVMService extends GBService {
|
||||||
acquire: acquire
|
acquire: acquire
|
||||||
},
|
},
|
||||||
define: {
|
define: {
|
||||||
|
// Disable timestamps globally
|
||||||
|
timestamps: false,
|
||||||
|
// Prevent createdAt/updatedAt from being selected
|
||||||
|
defaultScope: {
|
||||||
|
attributes: {
|
||||||
|
exclude: ['createdAt', 'updatedAt']
|
||||||
|
}
|
||||||
|
},
|
||||||
// Convert all table names to lowercase
|
// Convert all table names to lowercase
|
||||||
freezeTableName: true,
|
freezeTableName: true,
|
||||||
hooks: {
|
hooks: {
|
||||||
beforeDefine: (attributes, options) => {
|
beforeDefine: (attributes, options) => {
|
||||||
// Convert model name and table name to lowercase
|
// Convert model name and table name to lowercase
|
||||||
if (options.modelName) {
|
if (options.modelName) {
|
||||||
options.modelName = options.modelName.toLowerCase();
|
options.modelName = options.modelName.toLowerCase();
|
||||||
}
|
}
|
||||||
if (options.tableName) {
|
if (options.tableName) {
|
||||||
options.tableName = options.tableName.toLowerCase();
|
options.tableName = options.tableName.toLowerCase();
|
||||||
} else {
|
} else {
|
||||||
options.tableName = options.modelName.toLowerCase();
|
options.tableName = options.modelName.toLowerCase();
|
||||||
} for (const attr in attributes) {
|
} for (const attr in attributes) {
|
||||||
const lowered = attr.toLowerCase();
|
const lowered = attr.toLowerCase();
|
||||||
if (attr !== lowered) {
|
if (attr !== lowered) {
|
||||||
attributes[lowered] = attributes[attr];
|
attributes[lowered] = attributes[attr];
|
||||||
|
@ -427,7 +435,7 @@ export class GBVMService extends GBService {
|
||||||
const shouldSync = min.core.getParam<boolean>(min.instance, 'Synchronize Database', false);
|
const shouldSync = min.core.getParam<boolean>(min.instance, 'Synchronize Database', false);
|
||||||
|
|
||||||
tableDef.forEach(async t => {
|
tableDef.forEach(async t => {
|
||||||
const tableName = t.name.trim().toLowerCase ();
|
const tableName = t.name.trim().toLowerCase();
|
||||||
|
|
||||||
// Determines autorelationship.
|
// Determines autorelationship.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue