<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                ## **1、Mongoose 校驗參數** required : 表示這個數據必須傳入 max: 用于 Number 類型數據,最大值 min: 用于 Number 類型數據,最小值 enum:枚舉類型,要求數據必須滿足枚舉值 enum: ['0', '1', '2'] match:增加的數據必須符合match(正則)的規則 maxlength:最大值 minlength:最小值 ``` var UserSchema = new mongoose.Schema({ name:{ type:String, required: true, }, age: { type: Number, // 是否必須的校驗器 required: true, // 數字類型的最大值校驗器 max: 120, // 數字類型的最小值校驗器 min: 0 }, status: { type: String, // 設置字符串的可選值 enum: ['0', '1', '2'] }, phone:{ type:Number, match: /^\d{11}$/ }, desc: { type: String, maxlength:20, minlength:10 } }); ``` ## **2、Mongoose 自定義的驗證器** 在缺省情況下創建的索引均不是唯一索引。下面的示例將創建唯一索引,如: ``` var UserSchema = new mongoose.Schema({ name:{ type:String, required: true, }, age: { type: Number, // 是否必須的校驗器 required: true, // 數字類型的最大值校驗器 max: 120, // 數字類型的最小值校驗器 min: 0 }, status: { type: String, // 設置字符串的可選值 enum: ['0', '1', '2'] }, phone:{ type:Number, match: /^\d{11}$/ }, desc: { type: String, // 自定義的驗證器,如果通過驗證返回 true,沒有通過則返回 false validate: function(desc) { return desc.length >= 10; } } }); ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看