Browse Source

Merge pull request #7481 from AlexHladin/refactor/remove-duplicated-code

refactor: Remove duplicated code in DB models
pull/7485/head
Raju Udava 10 months ago committed by GitHub
parent
commit
f1668aec47
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  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; return columnsArr;
} }
protected renderXcHasMany(args) {
return JSON.stringify(args.hasMany);
}
protected renderXcBelongsTo(args) {
return JSON.stringify(args.belongsTo);
}
public getObject() { public getObject() {
return { return {
tn: this.ctx.tn, 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 */ /* for complex code provide a func and args - do derivation within the func cbk */
data.hasMany = { data.hasMany = {
func: this._renderXcHasMany.bind(this), func: this.renderXcHasMany.bind(this),
args: { args: {
tn: this.ctx.tn, tn: this.ctx.tn,
columns: this.ctx.columns, 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 */ /* for complex code provide a func and args - do derivation within the func cbk */
data.belongsTo = { data.belongsTo = {
func: this._renderXcBelongsTo.bind(this), func: this.renderXcBelongsTo.bind(this),
args: { args: {
tn: this.ctx.tn, tn: this.ctx.tn,
columns: this.ctx.columns, columns: this.ctx.columns,
@ -56,14 +56,6 @@ class ModelXcMetaMssql extends BaseModelXcMeta {
return data; return data;
} }
_renderXcHasMany(args) {
return JSON.stringify(args.hasMany);
}
_renderXcBelongsTo(args) {
return JSON.stringify(args.belongsTo);
}
/** /**
* *
* @param args * @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 */ /* for complex code provide a func and args - do derivation within the func cbk */
data.hasMany = { data.hasMany = {
func: this._renderXcHasMany.bind(this), func: this.renderXcHasMany.bind(this),
args: { args: {
tn: this.ctx.tn, tn: this.ctx.tn,
columns: this.ctx.columns, 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 */ /* for complex code provide a func and args - do derivation within the func cbk */
data.belongsTo = { data.belongsTo = {
func: this._renderXcBelongsTo.bind(this), func: this.renderXcBelongsTo.bind(this),
args: { args: {
dbType: this.ctx.dbType, dbType: this.ctx.dbType,
tn: this.ctx.tn, tn: this.ctx.tn,
@ -57,14 +57,6 @@ class ModelXcMetaMysql extends BaseModelXcMeta {
return data; return data;
} }
_renderXcHasMany(args) {
return JSON.stringify(args.hasMany);
}
_renderXcBelongsTo(args) {
return JSON.stringify(args.belongsTo);
}
/** /**
* *
* @param args * @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 */ /* for complex code provide a func and args - do derivation within the func cbk */
data.hasMany = { data.hasMany = {
func: this._renderXcHasMany.bind(this), func: this.renderXcHasMany.bind(this),
args: { args: {
tn: this.ctx.tn, tn: this.ctx.tn,
columns: this.ctx.columns, 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 */ /* for complex code provide a func and args - do derivation within the func cbk */
data.belongsTo = { data.belongsTo = {
func: this._renderXcBelongsTo.bind(this), func: this.renderXcBelongsTo.bind(this),
args: { args: {
dbType: this.ctx.dbType, dbType: this.ctx.dbType,
tn: this.ctx.tn, tn: this.ctx.tn,
@ -57,14 +57,6 @@ class ModelXcMetaOracle extends BaseModelXcMeta {
return data; return data;
} }
_renderXcHasMany(args) {
return JSON.stringify(args.hasMany);
}
_renderXcBelongsTo(args) {
return JSON.stringify(args.belongsTo);
}
/** /**
* *
* @param args * @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 */ /* for complex code provide a func and args - do derivation within the func cbk */
data.hasMany = { data.hasMany = {
func: this._renderXcHasMany.bind(this), func: this.renderXcHasMany.bind(this),
args: { args: {
tn: this.ctx.tn, tn: this.ctx.tn,
columns: this.ctx.columns, 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 */ /* for complex code provide a func and args - do derivation within the func cbk */
data.belongsTo = { data.belongsTo = {
func: this._renderXcBelongsTo.bind(this), func: this.renderXcBelongsTo.bind(this),
args: { args: {
tn: this.ctx.tn, tn: this.ctx.tn,
columns: this.ctx.columns, columns: this.ctx.columns,
@ -56,14 +56,6 @@ class ModelXcMetaPg extends BaseModelXcMeta {
return data; return data;
} }
_renderXcHasMany(args) {
return JSON.stringify(args.hasMany);
}
_renderXcBelongsTo(args) {
return JSON.stringify(args.belongsTo);
}
/** /**
* *
* @param args * @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 */ /* for complex code provide a func and args - do derivation within the func cbk */
data.hasMany = { data.hasMany = {
func: this._renderXcHasMany.bind(this), func: this.renderXcHasMany.bind(this),
args: { args: {
tn: this.ctx.tn, tn: this.ctx.tn,
columns: this.ctx.columns, 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 */ /* for complex code provide a func and args - do derivation within the func cbk */
data.belongsTo = { data.belongsTo = {
func: this._renderXcBelongsTo.bind(this), func: this.renderXcBelongsTo.bind(this),
args: { args: {
tn: this.ctx.tn, tn: this.ctx.tn,
columns: this.ctx.columns, columns: this.ctx.columns,
@ -56,14 +56,6 @@ class ModelXcMetaSnowflake extends BaseModelXcMeta {
return data; return data;
} }
_renderXcHasMany(args) {
return JSON.stringify(args.hasMany);
}
_renderXcBelongsTo(args) {
return JSON.stringify(args.belongsTo);
}
/** /**
* *
* @param args * @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 */ /* for complex code provide a func and args - do derivation within the func cbk */
data.hasMany = { data.hasMany = {
func: this._renderXcHasMany.bind(this), func: this.renderXcHasMany.bind(this),
args: { args: {
tn: this.ctx.tn, tn: this.ctx.tn,
columns: this.ctx.columns, 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 */ /* for complex code provide a func and args - do derivation within the func cbk */
data.belongsTo = { data.belongsTo = {
func: this._renderXcBelongsTo.bind(this), func: this.renderXcBelongsTo.bind(this),
args: { args: {
tn: this.ctx.tn, tn: this.ctx.tn,
columns: this.ctx.columns, columns: this.ctx.columns,
@ -56,14 +56,6 @@ class ModelXcMetaSqlite extends BaseModelXcMeta {
return data; return data;
} }
_renderXcHasMany(args) {
return JSON.stringify(args.hasMany);
}
_renderXcBelongsTo(args) {
return JSON.stringify(args.belongsTo);
}
/** /**
* *
* @param args * @param args

Loading…
Cancel
Save