【二】鸡汤来咯开发学习笔记-26

前端 · 2024-07-19

一.创建云数据库的表结构
1.新键DBSchema,根据文章模板创建(创建soup-chicken)

2.修改soup-chicken.schema.json根据自身需要

{
    "bsonType": "object",
    "required": [
        "content",
        "soup_type"
        
    ],
    "permission": {      //增删改查的权限
        "read": true,
        "create": true,
        "update": true,
        "delete": true
    },
    "properties": {
        "_id": {
            "description": "存储文档 ID(用户 ID),系统自动生成" //内容储存id生成
        },
        
        
        
        "content": {
            "bsonType": "string",//内容类型
            "title": "鸡汤内容", //起到标识的作用
            "trim": "both"//清楚两边的空格
        },
    
        "soup_type": {
            "bsonType": "int",
            "title": "鸡汤类型",
            "description": "鸡汤类型:0 毒鸡汤 1 心灵鸡汤",
            "defaultValue": 0,  //默认值为0
            "enum": [   //选项
                {
                    "value": 0,
                    "text": "毒鸡汤"
                },
                {
                    "value": 1,
                    "text": "心灵鸡汤"
                }
            ]
        },
        "view_count": {
            "bsonType": "int",
            "title": "阅读数量",
            "description": "阅读数量",
            "defaultValue":50       //默认50阅读
            
        },
        "like_count": {
            "bsonType": "int",
            "description": "喜欢数、点赞数",
            "defaultValue":0
        },
        "comment_count": {
            "bsonType": "int",
            "description": "评论数量",
            "defaultValue":0
            
        },
      "collect_count": {
          "bsonType": "int",
          "description": "收藏数量",
          "defaultValue":0
      },
        "status": {
            "bsonType": "int",
            "title": "鸡汤状态",
            "description": "状态:0 审核中  1 审核通过 2审核不通过",   //就是描述想写啥写啥,标识而已
            "defaultValue":1,
            "enum": [
                {
                    "value": 0,
                    "text": "审核中"
                },
                {
                    "value": 1,
                    "text": "审核通过"
                },
                {
                    "value":2,
                    "text":"审核不通过"
                }
            ]
        },
        "feedback":{     //反馈信息
            "bsonType": "string",     
            "title": "鸡汤内容",
            "trim": "both"
        },
        
        "publish_date": {
            "bsonType": "timestamp",
            "title": "发表时间",
            "description": "发表时间",
            "defaultValue": {
                "$env": "now"
            }
        },
        "publish_ip": {
            "bsonType": "string",
            "title": "发布鸡汤时IP地址",
            "forceDefaultValue": {
                "$env": "clientIP"
            }
        },
        "last_modify_date": {
            "bsonType": "timestamp",
            "title": "最后修改时间",
            "description": "最后修改时间",
            "defaultValue": {
                "$env": "now"
            }
        },
        "last_modify_ip": {
            "bsonType": "string",
            "description": "最后修改时 IP 地址",
            "forceDefaultValue": {
                "$env": "clientIP"
            }
        }
    },    
    "version": "0.0.1"
}

Theme Jasmine by Kent Liao