zoukankan      html  css  js  c++  java
  • mongo

    1、还原数据库

    mongorestore --username root --password root --authenticationDatabase admin --db geek mock

     2、语法

    //创建校验
    db.createCollection("students3", {
        validator: {
            $jsonSchema: {
                bsonType: "object",
                required: ["name", "year", "major", "address"],
                properties: {
                    name: {
                        bsonType: "string",
                        description: "must be a string and is required"
                    },
                    year: {
                        bsonType: "int",
                        minimum: 2017,
                        maximum: 3017,
                        description: "must be an integer in [ 2017, 3017 ] and is required"
                    },
                    major: {
                        enum: ["Math", "English", "Computer Science", "History", null],
                        description: "can only be one of the enum values and is required"
                    },
                    gpa: {
                        bsonType: ["double"],
                        description: "must be a double if the field exists"
                    },
                    address: {
                        bsonType: "object",
                        required: ["city"],
                        properties: {
                            street: {
                                bsonType: "string",
                                description: "must be a string if the field exists"
                            },
                            city: {
                                bsonType: "string",
                                "description": "must be a string and is required"
                            }
                        }
                    }
                }
            }
        }
    })
    //创建
    db.students3.insertOne({
        "name": "wang",
        "year": NumberInt("2019"),
        "major": "English",
        "address": {
            "city": "hz"
        }
    })

    3、BSON

  • 相关阅读:
    exkmp
    欧拉通路、回路
    你有多久没有看过星星
    trie树模板(统计难题)
    SPFA(热浪)
    codevs1958 刺激
    洛谷1290 欧几里得的游戏
    洛谷1016 旅行家的预算
    Spfa算法模板
    Tyvj2017清北冬令营入学测试
  • 原文地址:https://www.cnblogs.com/beaconSky/p/12360705.html
Copyright © 2011-2022 走看看