From 92fc4231b0720a3afaab8591795292fce6e2bd15 Mon Sep 17 00:00:00 2001 From: hdx Date: Thu, 27 Oct 2022 19:26:31 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20unicloud-db=20=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=E5=9C=A8=E5=BE=AE=E4=BF=A1=E5=B0=8F=E7=A8=8B=E5=BA=8F=E8=A1=A8?= =?UTF-8?q?=E5=90=8D=E9=BB=98=E8=AE=A4=E5=80=BC=E4=B8=BA=E7=A9=BA=E6=95=B0?= =?UTF-8?q?=E7=BB=84=E6=97=B6=E6=8A=A5=E9=94=99=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../uni-cli-shared/components/unicloud-db.vue | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/packages/uni-cli-shared/components/unicloud-db.vue b/packages/uni-cli-shared/components/unicloud-db.vue index 4440b8d60..0f3d5cba5 100644 --- a/packages/uni-cli-shared/components/unicloud-db.vue +++ b/packages/uni-cli-shared/components/unicloud-db.vue @@ -161,13 +161,6 @@ export default { }, isLookup () { return (Array.isArray(this.collection) && this.collection.length > 1) || (typeof this.collection === 'string' && this.collection.indexOf(',') > -1) - }, - mainCollection () { - if (typeof this.collection === 'string') { - return this.collection.split(',')[0] - } - const mainQuery = JSON.parse(JSON.stringify(this.collection[0])) - return mainQuery.$db[0].$param[0] } }, created () { @@ -335,7 +328,7 @@ export default { db = db.action(action) } - db.collection(this.mainCollection).add(value).then((res) => { + db.collection(this.getMainCollection()).add(value).then((res) => { success && success(res) if (showToast) { uni.showToast({ @@ -409,7 +402,7 @@ export default { db = db.action(action) } - return db.collection(this.mainCollection).doc(id).update(value).then((res) => { + return db.collection(this.getMainCollection()).doc(id).update(value).then((res) => { success && success(res) if (showToast) { uni.showToast({ @@ -431,6 +424,13 @@ export default { complete && complete() }) }, + getMainCollection () { + if (typeof this.collection === 'string') { + return this.collection.split(',')[0] + } + const mainQuery = JSON.parse(JSON.stringify(this.collection[0])) + return mainQuery.$db[0].$param[0] + }, getTemp (isTemp = true) { /* eslint-disable no-undef */ let db = uniCloud.database(this.spaceInfo) @@ -590,7 +590,7 @@ export default { exec = exec.action(action) } - exec.collection(this.mainCollection).where({ + exec.collection(this.getMainCollection()).where({ _id: dbCmd.in(ids) }).remove().then((res) => { success && success(res.result) -- GitLab