Browse Source

refactor: Remove duplicated code in DB models

pull/7481/head
AlexHladin 10 months ago
parent
commit
f2dc8e96b0
  1. 8
      packages/nocodb/src/db/sql-mgr/code/models/xc/BaseModelXcMeta.ts
  2. 12
      packages/nocodb/src/db/sql-mgr/code/models/xc/ModelXcMetaMssql.ts
  3. 12
      packages/nocodb/src/db/sql-mgr/code/models/xc/ModelXcMetaMysql.ts
  4. 12
      packages/nocodb/src/db/sql-mgr/code/models/xc/ModelXcMetaOracle.ts
  5. 12
      packages/nocodb/src/db/sql-mgr/code/models/xc/ModelXcMetaPg.ts
  6. 12
      packages/nocodb/src/db/sql-mgr/code/models/xc/ModelXcMetaSnowflake.ts
  7. 12
      packages/nocodb/src/db/sql-mgr/code/models/xc/ModelXcMetaSqlite.ts

8
packages/nocodb/src/db/sql-mgr/code/models/xc/BaseModelXcMeta.ts

@ -83,6 +83,14 @@ abstract class BaseModelXcMeta extends BaseRender {
return columnsArr;
}
protected renderXcHasMany(args) {
return JSON.stringify(args.hasMany);
}
protected renderXcBelongsTo(args) {
return JSON.stringify(args.belongsTo);
}
public getObject() {
return {
tn: this.ctx.tn,

12
packages/nocodb/src/db/sql-mgr/code/models/xc/ModelXcMetaMssql.ts

@ -35,7 +35,7 @@ class ModelXcMetaMssql extends BaseModelXcMeta {
/* for complex code provide a func and args - do derivation within the func cbk */
data.hasMany = {
func: this._renderXcHasMany.bind(this),
func: this.renderXcHasMany.bind(this),
args: {
tn: this.ctx.tn,
columns: this.ctx.columns,
@ -45,7 +45,7 @@ class ModelXcMetaMssql extends BaseModelXcMeta {
/* for complex code provide a func and args - do derivation within the func cbk */
data.belongsTo = {
func: this._renderXcBelongsTo.bind(this),
func: this.renderXcBelongsTo.bind(this),
args: {
tn: this.ctx.tn,
columns: this.ctx.columns,
@ -56,14 +56,6 @@ class ModelXcMetaMssql extends BaseModelXcMeta {
return data;
}
_renderXcHasMany(args) {
return JSON.stringify(args.hasMany);
}
_renderXcBelongsTo(args) {
return JSON.stringify(args.belongsTo);
}
/**
*
* @param args

12
packages/nocodb/src/db/sql-mgr/code/models/xc/ModelXcMetaMysql.ts

@ -35,7 +35,7 @@ class ModelXcMetaMysql extends BaseModelXcMeta {
/* for complex code provide a func and args - do derivation within the func cbk */
data.hasMany = {
func: this._renderXcHasMany.bind(this),
func: this.renderXcHasMany.bind(this),
args: {
tn: this.ctx.tn,
columns: this.ctx.columns,
@ -45,7 +45,7 @@ class ModelXcMetaMysql extends BaseModelXcMeta {
/* for complex code provide a func and args - do derivation within the func cbk */
data.belongsTo = {
func: this._renderXcBelongsTo.bind(this),
func: this.renderXcBelongsTo.bind(this),
args: {
dbType: this.ctx.dbType,
tn: this.ctx.tn,
@ -57,14 +57,6 @@ class ModelXcMetaMysql extends BaseModelXcMeta {
return data;
}
_renderXcHasMany(args) {
return JSON.stringify(args.hasMany);
}
_renderXcBelongsTo(args) {
return JSON.stringify(args.belongsTo);
}
/**
*
* @param args

12
packages/nocodb/src/db/sql-mgr/code/models/xc/ModelXcMetaOracle.ts

@ -35,7 +35,7 @@ class ModelXcMetaOracle extends BaseModelXcMeta {
/* for complex code provide a func and args - do derivation within the func cbk */
data.hasMany = {
func: this._renderXcHasMany.bind(this),
func: this.renderXcHasMany.bind(this),
args: {
tn: this.ctx.tn,
columns: this.ctx.columns,
@ -45,7 +45,7 @@ class ModelXcMetaOracle extends BaseModelXcMeta {
/* for complex code provide a func and args - do derivation within the func cbk */
data.belongsTo = {
func: this._renderXcBelongsTo.bind(this),
func: this.renderXcBelongsTo.bind(this),
args: {
dbType: this.ctx.dbType,
tn: this.ctx.tn,
@ -57,14 +57,6 @@ class ModelXcMetaOracle extends BaseModelXcMeta {
return data;
}
_renderXcHasMany(args) {
return JSON.stringify(args.hasMany);
}
_renderXcBelongsTo(args) {
return JSON.stringify(args.belongsTo);
}
/**
*
* @param args

12
packages/nocodb/src/db/sql-mgr/code/models/xc/ModelXcMetaPg.ts

@ -35,7 +35,7 @@ class ModelXcMetaPg extends BaseModelXcMeta {
/* for complex code provide a func and args - do derivation within the func cbk */
data.hasMany = {
func: this._renderXcHasMany.bind(this),
func: this.renderXcHasMany.bind(this),
args: {
tn: this.ctx.tn,
columns: this.ctx.columns,
@ -45,7 +45,7 @@ class ModelXcMetaPg extends BaseModelXcMeta {
/* for complex code provide a func and args - do derivation within the func cbk */
data.belongsTo = {
func: this._renderXcBelongsTo.bind(this),
func: this.renderXcBelongsTo.bind(this),
args: {
tn: this.ctx.tn,
columns: this.ctx.columns,
@ -56,14 +56,6 @@ class ModelXcMetaPg extends BaseModelXcMeta {
return data;
}
_renderXcHasMany(args) {
return JSON.stringify(args.hasMany);
}
_renderXcBelongsTo(args) {
return JSON.stringify(args.belongsTo);
}
/**
*
* @param args

12
packages/nocodb/src/db/sql-mgr/code/models/xc/ModelXcMetaSnowflake.ts

@ -35,7 +35,7 @@ class ModelXcMetaSnowflake extends BaseModelXcMeta {
/* for complex code provide a func and args - do derivation within the func cbk */
data.hasMany = {
func: this._renderXcHasMany.bind(this),
func: this.renderXcHasMany.bind(this),
args: {
tn: this.ctx.tn,
columns: this.ctx.columns,
@ -45,7 +45,7 @@ class ModelXcMetaSnowflake extends BaseModelXcMeta {
/* for complex code provide a func and args - do derivation within the func cbk */
data.belongsTo = {
func: this._renderXcBelongsTo.bind(this),
func: this.renderXcBelongsTo.bind(this),
args: {
tn: this.ctx.tn,
columns: this.ctx.columns,
@ -56,14 +56,6 @@ class ModelXcMetaSnowflake extends BaseModelXcMeta {
return data;
}
_renderXcHasMany(args) {
return JSON.stringify(args.hasMany);
}
_renderXcBelongsTo(args) {
return JSON.stringify(args.belongsTo);
}
/**
*
* @param args

12
packages/nocodb/src/db/sql-mgr/code/models/xc/ModelXcMetaSqlite.ts

@ -35,7 +35,7 @@ class ModelXcMetaSqlite extends BaseModelXcMeta {
/* for complex code provide a func and args - do derivation within the func cbk */
data.hasMany = {
func: this._renderXcHasMany.bind(this),
func: this.renderXcHasMany.bind(this),
args: {
tn: this.ctx.tn,
columns: this.ctx.columns,
@ -45,7 +45,7 @@ class ModelXcMetaSqlite extends BaseModelXcMeta {
/* for complex code provide a func and args - do derivation within the func cbk */
data.belongsTo = {
func: this._renderXcBelongsTo.bind(this),
func: this.renderXcBelongsTo.bind(this),
args: {
tn: this.ctx.tn,
columns: this.ctx.columns,
@ -56,14 +56,6 @@ class ModelXcMetaSqlite extends BaseModelXcMeta {
return data;
}
_renderXcHasMany(args) {
return JSON.stringify(args.hasMany);
}
_renderXcBelongsTo(args) {
return JSON.stringify(args.belongsTo);
}
/**
*
* @param args

Loading…
Cancel
Save