From f652002ade74e1de2ea3b8879db35a4038684579 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E4=BA=9A=E7=90=AA?= Date: Thu, 9 May 2024 12:05:43 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E5=90=88=E5=B9=B6?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E8=AF=B7=E6=B1=82=E7=A4=BA=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unicloud-database.test.js | 3 ++ .../unicloud-database/unicloud-database.uvue | 35 +++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/pages/API/unicloud-database/unicloud-database.test.js b/pages/API/unicloud-database/unicloud-database.test.js index 80855554..cec19a63 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 aeb650c1..36cb30f4 100644 --- a/pages/API/unicloud-database/unicloud-database.uvue +++ b/pages/API/unicloud-database/unicloud-database.uvue @@ -14,6 +14,7 @@ + @@ -35,6 +36,7 @@ getWithCommandData: [] as Array, removeDeleted: 0, lookupData: [] as Array, + multiSendSuccessCount: 0, isUniTest: false } }, @@ -278,6 +280,39 @@ 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() + let successCount = 0 + for (let i = 0; i < res.dataList.length; i++) { + const item = res.dataList[i] + if(item.errCode == 0) { + console.log(`第${i}个请求查询到${item.data!.length}条数据`) + successCount++ + } else { + console.error(`第${i}个请求查询失败,错误信息:${item.data!.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, '错误') + }) } } } -- GitLab