From b42731512768b4b9e201c820222a259779bd48e7 Mon Sep 17 00:00:00 2001 From: linju Date: Mon, 23 Oct 2023 17:31:51 +0800 Subject: [PATCH] =?UTF-8?q?notice=20=E8=A1=A8=E6=94=B9=E4=B8=BA=20opendb-n?= =?UTF-8?q?otice?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/clientDB/demo/demo.vue | 2 +- .../uni-clientDB-actions/add_view_count.js | 2 +- uniCloud-aliyun/database/db_init.json | 2 +- uniCloud-aliyun/database/notice.schema.json | 40 ---------------- .../database/opendb-notice.schema.json | 48 +++++++++++++++++++ 5 files changed, 51 insertions(+), 43 deletions(-) delete mode 100644 uniCloud-aliyun/database/notice.schema.json create mode 100644 uniCloud-aliyun/database/opendb-notice.schema.json diff --git a/pages/clientDB/demo/demo.vue b/pages/clientDB/demo/demo.vue index 8f60da9..0ff9034 100644 --- a/pages/clientDB/demo/demo.vue +++ b/pages/clientDB/demo/demo.vue @@ -130,7 +130,7 @@ }, async getNoticeData() { let res = await db.action('add_view_count') - .collection('notice') + .collection('opendb-notice') .field('data,_id,update_time,view_count') .get(); console.log("res: ",res); diff --git a/uniCloud-aliyun/cloudfunctions/uni-clientDB-actions/add_view_count.js b/uniCloud-aliyun/cloudfunctions/uni-clientDB-actions/add_view_count.js index bc78be9..d1f32df 100644 --- a/uniCloud-aliyun/cloudfunctions/uni-clientDB-actions/add_view_count.js +++ b/uniCloud-aliyun/cloudfunctions/uni-clientDB-actions/add_view_count.js @@ -6,7 +6,7 @@ module.exports = { }, after: async (state, event, error, result) => { - await db.collection('notice').update({ + await db.collection('opendb-notice').update({ view_count:$cmd.inc(1) }) if (error) { diff --git a/uniCloud-aliyun/database/db_init.json b/uniCloud-aliyun/database/db_init.json index 45a629b..3016be6 100644 --- a/uniCloud-aliyun/database/db_init.json +++ b/uniCloud-aliyun/database/db_init.json @@ -144,7 +144,7 @@ "data": [{"state":0,"text":"该用户比较懒啥也没写!"}] }, "comment": {}, - "notice": { + "opendb-notice": { "data": [{ "view_count": 0, "data": "这是一个由clientDB实现的留言板示例;权限部分由DBschema和action云函数控制。\n规则如下:\n 1.未登陆的游客,只能看到审核通过的留言。\n 2.登陆的用户还可以:发表留言,会进入审核状态,期间支持查看和删除。审核通过后可以重新编辑留言。但在重新编辑后会自动再次进入审核状态。\n 3.审核员和管理员可以:查看所有状态的留言,操作:审核、编辑、删除。" diff --git a/uniCloud-aliyun/database/notice.schema.json b/uniCloud-aliyun/database/notice.schema.json deleted file mode 100644 index 83e8060..0000000 --- a/uniCloud-aliyun/database/notice.schema.json +++ /dev/null @@ -1,40 +0,0 @@ -// 文档教程: https://uniapp.dcloud.net.cn/uniCloud/schema -{ - "bsonType": "object", - "required": [], - "permission": { - "read": "action in 'add_view_count'", - "create": false, - "update": false, - "delete": false - }, - "properties": { - "_id": { - "description": "ID,系统自动生成", - "foreignKey": "comment.notice_id" - }, - "data":{ - "bsonType":"string", - "description":"公告内容", - "label":"公告内容", - "maxLength":32, - "errorMessage":{ - "maxLength": "{label}不能大于{maxLength}个字符" - } - }, - "view_count": { - "bsonType": "int", - "title": "阅读数量", - "description": "阅读数量", - "permission": { - "write": false - } - }, - "update_time":{ - "bsonType":"timestamp", - "forceDefaultValue":{ - "$env":"now" - } - } - } -} \ No newline at end of file diff --git a/uniCloud-aliyun/database/opendb-notice.schema.json b/uniCloud-aliyun/database/opendb-notice.schema.json new file mode 100644 index 0000000..1baa5f4 --- /dev/null +++ b/uniCloud-aliyun/database/opendb-notice.schema.json @@ -0,0 +1,48 @@ +// 文档教程: https://uniapp.dcloud.net.cn/uniCloud/schema +{ + "bsonType": "object", + "required": [], + "permission": { + "read": "action in 'add_view_count'", + "create": false, + "update": false, + "delete": false + }, + "properties": { + "_id": { + "description": "ID,系统自动生成", + "foreignKey": "comment.notice_id" + }, + "data": { + "bsonType": "string", + "description": "公告内容", + "label": "公告内容", + "maxLength": 32, + "errorMessage": { + "maxLength": "{label}不能大于{maxLength}个字符" + } + }, + "view_count": { + "bsonType": "int", + "title": "阅读数量", + "description": "阅读数量", + "permission": { + "write": false + } + }, + "create_time": { + "description": "创建时间", + "bsonType": "timestamp", + "forceDefaultValue": { + "$env": "now" + } + }, + "update_time": { + "description": "更新时间", + "bsonType": "timestamp", + "forceDefaultValue": { + "$env": "now" + } + } + } +} \ No newline at end of file -- GitLab