mirror of
https://github.com/nocodb/nocodb.git
synced 2026-05-05 07:07:11 +00:00
@@ -2,7 +2,6 @@ import inflection from 'inflection'
|
||||
|
||||
export default class GqlApi {
|
||||
constructor(table, columns, meta, $ctx) {
|
||||
// this.table = table;
|
||||
this.columns = columns
|
||||
this.meta = meta
|
||||
this.$ctx = $ctx
|
||||
@@ -70,19 +69,19 @@ export default class GqlApi {
|
||||
}
|
||||
|
||||
get gqlQueryListName() {
|
||||
return `${this.meta._tn}List`
|
||||
return `${this.meta.title}List`
|
||||
}
|
||||
|
||||
get gqlQueryReadName() {
|
||||
return `${this.meta._tn}Read`
|
||||
return `${this.meta.title}Read`
|
||||
}
|
||||
|
||||
get tableCamelized() {
|
||||
return `${this.meta._tn}`
|
||||
return `${this.meta.title}`
|
||||
}
|
||||
|
||||
get gqlReqBody() {
|
||||
return `\n${this.columns.map(c => c._cn).join('\n')}\n`
|
||||
return `\n${this.columns.map(c => c.title).join('\n')}\n`
|
||||
}
|
||||
|
||||
async gqlRelationReqBody(params) {
|
||||
@@ -92,11 +91,11 @@ export default class GqlApi {
|
||||
await this.$ctx.$store.dispatch('meta/ActLoadMeta', {
|
||||
dbAlias: this.$ctx.nodes.dbAlias,
|
||||
env: this.$ctx.nodes.env,
|
||||
tn: child
|
||||
table_name: child
|
||||
})
|
||||
const meta = this.$ctx.$store.state.meta.metas[child]
|
||||
if (meta) {
|
||||
str += `\n${meta._tn}List{\n${meta.columns.map(c => c._cn).join('\n')}\n}`
|
||||
str += `\n${meta.title}List{\n${meta.columns.map(c => c.title).join('\n')}\n}`
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -105,11 +104,11 @@ export default class GqlApi {
|
||||
await this.$ctx.$store.dispatch('meta/ActLoadMeta', {
|
||||
dbAlias: this.$ctx.nodes.dbAlias,
|
||||
env: this.$ctx.nodes.env,
|
||||
tn: parent
|
||||
table_name: parent
|
||||
})
|
||||
const meta = this.$ctx.$store.state.meta.metas[parent]
|
||||
if (meta) {
|
||||
str += `\n${meta._tn}Read{\n${meta.columns.map(c => c._cn).join('\n')}\n}`
|
||||
str += `\n${meta.title}Read{\n${meta.columns.map(c => c.title).join('\n')}\n}`
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -118,11 +117,11 @@ export default class GqlApi {
|
||||
await this.$ctx.$store.dispatch('meta/ActLoadMeta', {
|
||||
dbAlias: this.$ctx.nodes.dbAlias,
|
||||
env: this.$ctx.nodes.env,
|
||||
tn: mm
|
||||
table_name: mm
|
||||
})
|
||||
const meta = this.$ctx.$store.state.meta.metas[mm]
|
||||
if (meta) {
|
||||
str += `\n${meta._tn}MMList{\n${meta.columns.map(c => c._cn).join('\n')}\n}`
|
||||
str += `\n${meta.title}MMList{\n${meta.columns.map(c => c.title).join('\n')}\n}`
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -170,7 +169,7 @@ export default class GqlApi {
|
||||
|
||||
const colName = Object.keys(data)[0]
|
||||
this.$ctx.$store.dispatch('sqlMgr/ActSqlOp', [{ dbAlias: this.$ctx.nodes.dbAlias }, 'xcAuditCreate', {
|
||||
tn: this.table,
|
||||
table_name: this.table,
|
||||
cn: colName,
|
||||
pk: id,
|
||||
value: data[colName],
|
||||
@@ -216,7 +215,7 @@ export default class GqlApi {
|
||||
}
|
||||
|
||||
get table() {
|
||||
return this.meta && this.meta._tn && inflection.camelize(this.meta._tn)
|
||||
return this.meta && this.meta.title && inflection.camelize(this.meta.title)
|
||||
}
|
||||
|
||||
async paginatedM2mNotChildrenList(params, assoc, pid) {
|
||||
@@ -225,7 +224,7 @@ export default class GqlApi {
|
||||
m2mNotChildren(pid: $pid,assoc:$assoc,parent:$parent,limit:$limit, offset:$offset)
|
||||
}`,
|
||||
variables: {
|
||||
parent: this.meta.tn, assoc, pid: pid + '', ...params
|
||||
parent: this.meta.table_name, assoc, pid: pid + '', ...params
|
||||
}
|
||||
})
|
||||
const count = await this.post(`/nc/${this.$ctx.$route.params.project_id}/v1/graphql`, {
|
||||
@@ -233,7 +232,7 @@ export default class GqlApi {
|
||||
m2mNotChildrenCount(pid: $pid,assoc:$assoc,parent:$parent)
|
||||
}`,
|
||||
variables: {
|
||||
parent: this.meta.tn, assoc, pid: pid + ''
|
||||
parent: this.meta.table_name, assoc, pid: pid + ''
|
||||
}
|
||||
})
|
||||
return { list: list.data.data.m2mNotChildren, count: count.data.data.m2mNotChildrenCount.count }
|
||||
|
||||
Reference in New Issue
Block a user