diff --git a/pages/API/unicloud-database/unicloud-database.test.js b/pages/API/unicloud-database/unicloud-database.test.js index 80855554214ae8f9c53506ab411ba8ddcbe35334..cec19a63b982c7d2461344fa0bb682f917934fb4 100644 --- a/pages/API/unicloud-database/unicloud-database.test.js +++ b/pages/API/unicloud-database/unicloud-database.test.js @@ -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) }) diff --git a/pages/API/unicloud-database/unicloud-database.uvue b/pages/API/unicloud-database/unicloud-database.uvue index aeb650c1553e4a9dc95de3202d4ca9f811cfecfc..ce321e79a22008df1e4338955a7c17eb10183af6 100644 --- a/pages/API/unicloud-database/unicloud-database.uvue +++ b/pages/API/unicloud-database/unicloud-database.uvue @@ -35,6 +35,7 @@ getWithCommandData: [] as Array, removeDeleted: 0, lookupData: [] as Array, + 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(res => { + uni.hideLoading() + const successCount = res.dataList.filter((item: UniCloudDBMultiSendResultItem) : boolean => { + return item.errCode == 0 + }).length + this.multiSendSuccessCount = successCount + this.notify(`合并查询成功,成功查询的语句条数为:${successCount}`, '提示') + }) + .catch((err : any | null) => { + uni.hideLoading() + const error = err as UniCloudError + console.error(err) + this.notify(error.errMsg, '错误') + }) } } }