diff --git a/packages/uni-cli-shared/components/unicloud-db.vue b/packages/uni-cli-shared/components/unicloud-db.vue index c5ac2137c9458decc1293ca058a1f0a7035673cc..92a4933ae156b6a06f70f6a937f77db58bb0eb84 100644 --- a/packages/uni-cli-shared/components/unicloud-db.vue +++ b/packages/uni-cli-shared/components/unicloud-db.vue @@ -314,7 +314,7 @@ export default { db = db.action(action) } - db.collection(this.collection).add(value).then((res) => { + db.collection(this._getCollection()).add(value).then((res) => { success && success(res) if (showToast) { uni.showToast({ @@ -388,7 +388,7 @@ export default { db = db.action(action) } - return db.collection(this.collection).doc(id).update(value).then((res) => { + return db.collection(this._getCollection()).doc(id).update(value).then((res) => { success && success(res) if (showToast) { uni.showToast({ @@ -546,9 +546,7 @@ export default { exec = exec.action(action) } - const collection = this.collection.indexOf(',') > 0 ? this.collection.substring(0, this.collection.indexOf(',')) : this.collection - - exec.collection(collection).where({ + exec.collection(this._getCollection()).where({ _id: dbCmd.in(ids) }).remove().then((res) => { success && success(res.result) @@ -572,6 +570,11 @@ export default { complete && complete() }) }, + _getCollection() { + const index = this.collection.indexOf(',') + const collection = index > 0 ? this.collection.substring(0, index) : this.collection + return collection + }, removeData (ids) { const il = ids.slice(0) const dl = this.dataList