diff --git a/pages/clientDB/demo/demo.vue b/pages/clientDB/demo/demo.vue index 8f60da957244645e330292d197c344289da2d680..0ff90347789bfcaaabfd03c201e919ed3dee4020 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 bc78be9e2847267aeb4ca31666107f4336324464..d1f32dfd34e48e1a1f7f225f405d33a177a981de 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 45a629b33c9030f77efba3eb5f60e37d647ee030..3016be613c7d0cbea53dba59e153d84e463e94d5 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 83e80608094a8b5cba056bdc8e11e091ee29af85..0000000000000000000000000000000000000000 --- 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 0000000000000000000000000000000000000000..1baa5f41a5f420240af4932c36c6aef3cd5c0f1c --- /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