提交 7bf10262 编写于 作者: 雪洛's avatar 雪洛

feat: 新增uniCloud database multiSend方法

上级 d32fef4d
......@@ -17,6 +17,7 @@ describe('unicloud-database', () => {
await page.callMethod('dbGetWithCommand')
await page.callMethod('dbUpdate')
await page.callMethod('dbRemove')
await page.callMethod('dbMultiSend')
const {
addId,
......@@ -26,6 +27,7 @@ describe('unicloud-database', () => {
getData,
getWithCommandData,
removeDeleted,
multiSendSuccessCount,
} = await page.data()
expect(addId !== '').toBe(true)
......@@ -35,6 +37,7 @@ describe('unicloud-database', () => {
expect(getWithCommandData.length).toBe(1)
expect(updateUpdated).toBe(3)
expect(removeDeleted).toBe(3)
expect(multiSendSuccessCount).toBe(2)
})
......
......@@ -35,6 +35,7 @@
getWithCommandData: [] as Array<UTSJSONObject>,
removeDeleted: 0,
lookupData: [] as Array<UTSJSONObject>,
multiSendSuccessCount: 0,
isUniTest: false
}
},
......@@ -278,6 +279,32 @@
const error = err as UniCloudError
this.notify(error.errMsg, '错误')
})
},
dbMultiSend() {
const db = uniCloud.databaseForJQL()
const temp1 = db.collection('type')
.where(
'tag == "default-tag"'
).getTemp()
const temp2 = db.collection('type')
.where(
'tag == "default-tag"'
).getTemp()
db.multiSend(temp1, temp2)
.then<void>(res => {
uni.hideLoading()
const successCount = res.dataList.filter((item: UniCloudDBMultiSendResultItem) : boolean => {
return item.errCode == 0
}).length
this.multiSendSuccessCount = successCount
this.notify(`合并查询成功,成功查询的语句条数为:${successCount}`, '提示')
})
.catch<void>((err : any | null) => {
uni.hideLoading()
const error = err as UniCloudError
console.error(err)
this.notify(error.errMsg, '错误')
})
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册