|
|
@ -668,7 +668,7 @@ export default abstract class BaseApiBuilder<T extends Noco> implements XcDynami |
|
|
|
|
|
|
|
|
|
|
|
const NC_VERSIONS = [ |
|
|
|
const NC_VERSIONS = [ |
|
|
|
{name: '0009000', handler: null}, |
|
|
|
{name: '0009000', handler: null}, |
|
|
|
{name: '0009044', handler: this.xcUpManyToMany} |
|
|
|
{name: '0009044', handler: this.ncUpManyToMany} |
|
|
|
] |
|
|
|
] |
|
|
|
if (!await this.xcMeta?.knex?.schema?.hasTable?.('nc_store')) { |
|
|
|
if (!await this.xcMeta?.knex?.schema?.hasTable?.('nc_store')) { |
|
|
|
return; |
|
|
|
return; |
|
|
@ -1660,22 +1660,29 @@ export default abstract class BaseApiBuilder<T extends Noco> implements XcDynami |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private async xcUpManyToMany(): Promise<any> { |
|
|
|
protected async ncUpManyToMany(): Promise<any> { |
|
|
|
const metas = await this.xcMeta.metaList(this.projectId, this.dbAlias, 'xc_models', { |
|
|
|
const models = await this.xcMeta.metaList(this.projectId, this.dbAlias, 'nc_models', { |
|
|
|
fields: ['meta'] |
|
|
|
fields: ['meta'] |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
if (!models.length) { |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
const metas = []; |
|
|
|
// add virtual columns for relations
|
|
|
|
// add virtual columns for relations
|
|
|
|
for (const {meta: metaJson} of metas) { |
|
|
|
for (const metaObj of models) { |
|
|
|
const meta = JSON.parse(metaJson.meta); |
|
|
|
const meta = JSON.parse(metaObj.meta); |
|
|
|
|
|
|
|
metas.push(meta); |
|
|
|
const ctx = this.generateContextForTable(meta.tn, meta.columns, [], meta.hasMany, meta.belongsTo, meta.type, meta._tn); |
|
|
|
const ctx = this.generateContextForTable(meta.tn, meta.columns, [], meta.hasMany, meta.belongsTo, meta.type, meta._tn); |
|
|
|
meta.v = ModelXcMetaFactory.create(this.connectionConfig, {dir: '', ctx, filename: ''}).getVitualColumns(); |
|
|
|
meta.v = ModelXcMetaFactory.create(this.connectionConfig, {dir: '', ctx, filename: ''}).getVitualColumns(); |
|
|
|
await this.xcMeta.metaUpdate(this.projectId, this.dbAlias, 'xc_models', { |
|
|
|
ModelXcMetaFactory.create(this.connectionConfig, {}).mapDefaultPrimaryValue(meta.columns); |
|
|
|
|
|
|
|
await this.xcMeta.metaUpdate(this.projectId, this.dbAlias, 'nc_models', { |
|
|
|
meta: JSON.stringify(meta) |
|
|
|
meta: JSON.stringify(meta) |
|
|
|
}, {title: meta.tn}) |
|
|
|
}, {title: meta.tn}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// generate many to many relations an columns
|
|
|
|
// generate many to many relations an columns
|
|
|
|
await this.getManyToManyRelations(); |
|
|
|
await this.getManyToManyRelations(); |
|
|
|
|
|
|
|
return metas; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|