From bd12ea18aab44f0da8692de6679174b30bb046e9 Mon Sep 17 00:00:00 2001 From: hdx Date: Thu, 19 Oct 2023 19:15:47 +0800 Subject: [PATCH] =?UTF-8?q?feat(unicloud-db=E7=BB=84=E4=BB=B6):=20?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=87=AA=E5=8A=A8=E5=8C=96=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/unicloud-db/unicloud-db.test.js | 31 +++ pages/component/unicloud-db/unicloud-db.uvue | 180 ++++++++++++++++++ .../database/unicloud-db-test.schema.json | 40 ++++ 3 files changed, 251 insertions(+) create mode 100644 pages/component/unicloud-db/unicloud-db.test.js create mode 100644 pages/component/unicloud-db/unicloud-db.uvue create mode 100644 uniCloud-aliyun/database/unicloud-db-test.schema.json diff --git a/pages/component/unicloud-db/unicloud-db.test.js b/pages/component/unicloud-db/unicloud-db.test.js new file mode 100644 index 00000000..0d93113a --- /dev/null +++ b/pages/component/unicloud-db/unicloud-db.test.js @@ -0,0 +1,31 @@ +const PAGE_PATH = '/pages/unicloud-db/unicloud-db' + +describe('unicloud-db', () => { + let page + beforeAll(async () => { + page = await program.reLaunch(PAGE_PATH) + await page.waitFor(500) + }) + it('add/get/update/remove', async () => { + await page.callMethod('add') + await page.waitFor(3000) + const { + $addResult + } = await page.data() + expect($addResult['id'].length > 0).toBe(true) + + await page.callMethod('update', $addResult['id']) + await page.waitFor(3000) + const { + $updateResult + } = await page.data() + expect($updateResult['updated']).toBe(1) + + await page.callMethod('remove', $addResult['id']) + await page.waitFor(3000) + const { + $removeResult + } = await page.data() + expect($removeResult['deleted']).toBe(1) + }) +}) \ No newline at end of file diff --git a/pages/component/unicloud-db/unicloud-db.uvue b/pages/component/unicloud-db/unicloud-db.uvue new file mode 100644 index 00000000..9bec1956 --- /dev/null +++ b/pages/component/unicloud-db/unicloud-db.uvue @@ -0,0 +1,180 @@ + + + + + \ No newline at end of file diff --git a/uniCloud-aliyun/database/unicloud-db-test.schema.json b/uniCloud-aliyun/database/unicloud-db-test.schema.json new file mode 100644 index 00000000..7f4a6944 --- /dev/null +++ b/uniCloud-aliyun/database/unicloud-db-test.schema.json @@ -0,0 +1,40 @@ +{ + "bsonType": "object", + "permission": { + "read": true, + "create": true, + "update": true, + "delete": true + }, + "required": ["title", "comment"], + "properties": { + "_id": { + "description": "存储文档 ID(用户 ID),系统自动生成" + }, + "title": { + "bsonType": "string", + "title": "姓名", + "description": "姓名", + "order": 1, + "trim": "both" + }, + "comment": { + "bsonType": "string", + "title": "备注", + "order": 5, + "description": "备注", + "trim": "both", + "component": { + "name": "textarea" + } + }, + "create_date": { + "bsonType": "timestamp", + "description": "创建时间", + "forceDefaultValue": { + "$env": "now" + } + } + }, + "version": "0.0.1" +} \ No newline at end of file -- GitLab