提交 92fc4231 编写于 作者: d-u-a's avatar d-u-a

fix: unicloud-db 组件在微信小程序表名默认值为空数组时报错的问题

上级 af174247
...@@ -161,13 +161,6 @@ export default { ...@@ -161,13 +161,6 @@ export default {
}, },
isLookup () { isLookup () {
return (Array.isArray(this.collection) && this.collection.length > 1) || (typeof this.collection === 'string' && this.collection.indexOf(',') > -1) 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 () { created () {
...@@ -335,7 +328,7 @@ export default { ...@@ -335,7 +328,7 @@ export default {
db = db.action(action) db = db.action(action)
} }
db.collection(this.mainCollection).add(value).then((res) => { db.collection(this.getMainCollection()).add(value).then((res) => {
success && success(res) success && success(res)
if (showToast) { if (showToast) {
uni.showToast({ uni.showToast({
...@@ -409,7 +402,7 @@ export default { ...@@ -409,7 +402,7 @@ export default {
db = db.action(action) 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) success && success(res)
if (showToast) { if (showToast) {
uni.showToast({ uni.showToast({
...@@ -431,6 +424,13 @@ export default { ...@@ -431,6 +424,13 @@ export default {
complete && complete() 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) { getTemp (isTemp = true) {
/* eslint-disable no-undef */ /* eslint-disable no-undef */
let db = uniCloud.database(this.spaceInfo) let db = uniCloud.database(this.spaceInfo)
...@@ -590,7 +590,7 @@ export default { ...@@ -590,7 +590,7 @@ export default {
exec = exec.action(action) exec = exec.action(action)
} }
exec.collection(this.mainCollection).where({ exec.collection(this.getMainCollection()).where({
_id: dbCmd.in(ids) _id: dbCmd.in(ids)
}).remove().then((res) => { }).remove().then((res) => {
success && success(res.result) success && success(res.result)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册