|
|
@ -2126,8 +2126,11 @@ export default abstract class BaseApiBuilder<T extends Noco> |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected async syncRelations(): Promise<boolean> { |
|
|
|
protected async syncRelations(): Promise<boolean> { |
|
|
|
const [relations, missingRelations] = await this.getRelationsAndMissingRelations() |
|
|
|
const [ |
|
|
|
if(!missingRelations) return false; |
|
|
|
relations, |
|
|
|
|
|
|
|
missingRelations |
|
|
|
|
|
|
|
] = await this.getRelationsAndMissingRelations(); |
|
|
|
|
|
|
|
if (!missingRelations) return false; |
|
|
|
|
|
|
|
|
|
|
|
this.relationsCount = relations.length + missingRelations.length; |
|
|
|
this.relationsCount = relations.length + missingRelations.length; |
|
|
|
|
|
|
|
|
|
|
@ -2158,7 +2161,7 @@ export default abstract class BaseApiBuilder<T extends Noco> |
|
|
|
|
|
|
|
|
|
|
|
protected async getRelationsAndMissingRelations(): Promise<[any, any]> { |
|
|
|
protected async getRelationsAndMissingRelations(): Promise<[any, any]> { |
|
|
|
// Relations in metadata
|
|
|
|
// Relations in metadata
|
|
|
|
let relations = await this.xcMeta.metaList( |
|
|
|
const relations = await this.xcMeta.metaList( |
|
|
|
this.projectId, |
|
|
|
this.projectId, |
|
|
|
this.dbAlias, |
|
|
|
this.dbAlias, |
|
|
|
'nc_relations', |
|
|
|
'nc_relations', |
|
|
@ -2177,7 +2180,6 @@ export default abstract class BaseApiBuilder<T extends Noco> |
|
|
|
'db_type', |
|
|
|
'db_type', |
|
|
|
'dr', |
|
|
|
'dr', |
|
|
|
'fkn' |
|
|
|
'fkn' |
|
|
|
|
|
|
|
|
|
|
|
] |
|
|
|
] |
|
|
|
} |
|
|
|
} |
|
|
|
); |
|
|
|
); |
|
|
@ -2186,13 +2188,15 @@ export default abstract class BaseApiBuilder<T extends Noco> |
|
|
|
const dbRelations = (await this.sqlClient.relationListAll())?.data?.list; |
|
|
|
const dbRelations = (await this.sqlClient.relationListAll())?.data?.list; |
|
|
|
|
|
|
|
|
|
|
|
// Relations missing in metadata
|
|
|
|
// Relations missing in metadata
|
|
|
|
const missingRelations = dbRelations.filter(dbRelation => { |
|
|
|
const missingRelations = dbRelations |
|
|
|
return relations.every(relation => relation?.fkn !== dbRelation?.cstn) |
|
|
|
.filter(dbRelation => { |
|
|
|
}).map(relation => { |
|
|
|
return relations.every(relation => relation?.fkn !== dbRelation?.cstn); |
|
|
|
relation.enabled = true; |
|
|
|
}) |
|
|
|
relation.fkn = relation?.cstn; |
|
|
|
.map(relation => { |
|
|
|
return relation |
|
|
|
relation.enabled = true; |
|
|
|
}); |
|
|
|
relation.fkn = relation?.cstn; |
|
|
|
|
|
|
|
return relation; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
return [relations, missingRelations]; |
|
|
|
return [relations, missingRelations]; |
|
|
|
} |
|
|
|
} |
|
|
@ -2929,6 +2933,20 @@ export default abstract class BaseApiBuilder<T extends Noco> |
|
|
|
public getMeta(tableName: string): any { |
|
|
|
public getMeta(tableName: string): any { |
|
|
|
return this.metas?.[tableName]; |
|
|
|
return this.metas?.[tableName]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
protected async getOrderVal(): Promise<number> { |
|
|
|
|
|
|
|
const order = |
|
|
|
|
|
|
|
( |
|
|
|
|
|
|
|
await this.xcMeta |
|
|
|
|
|
|
|
.knex('nc_models') |
|
|
|
|
|
|
|
.where({ |
|
|
|
|
|
|
|
project_id: this.projectId, |
|
|
|
|
|
|
|
db_alias: this.dbAlias |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
.max('order as max') |
|
|
|
|
|
|
|
.first() |
|
|
|
|
|
|
|
)?.max || 0; |
|
|
|
|
|
|
|
return order; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export { IGNORE_TABLES }; |
|
|
|
export { IGNORE_TABLES }; |
|
|
|