<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國際加速解決方案。 廣告
                [TOC] ### mongoose 復雜模型 #### 仿知乎個人資料建模 * [ ] 分析 ![](https://box.kancloud.cn/7ed7f97e48325e7b4df45a7f1dd9dbf5_982x668.png) ~~~ // 引入 mongoose const mongoose = require('mongoose') const { Schema, model } = mongoose // 創建用戶Schema const userSchema = new Schema({ __v: { type: Number, select: false }, // 用戶名 username: { type: String, required: true }, // 登錄密碼 password: { type: String, required: true, select: false }, // 用戶頭像 avatar: { type: String }, // 用戶性別 gender: { type: String, required: true, enum: ['male', 'female', 'secrecy'], default: 'secrecy', }, // 個人簡介 introduce: { type: String }, // 居住地 residence: { // 字符串數組 type: [{type: String}] }, //行業 industry: { type: String }, // 職業經歷 Career:{ type: [{ // 公司名稱 corporate: {type: String}, // 職位 job: {type: String} }] }, // 教育經歷 experience: { type: [{ // 機構名稱 title: {type: String}, // 專業方向 major: {type: String}, // 學歷 enum: [1,2,3,4,5] 高中,本科,碩士,博士 Education: { type: Number, enum: [1,2,3,4,5]}, // 入學年份 enrollment_year: { type: Number}, // 畢業年份 graduation_year: {type: Number} }] } }) // 生成用戶模型 module.exports = model('User', userSchema) ~~~ ***** * [ ] 建模思路 1. 性別建模 ![](https://box.kancloud.cn/cb92cdd30998849ceb69490baebcac06_393x134.png) ``` // 用戶性別 gender: { type: String, required: true, enum: ['male', 'female', 'secrecy'], default: 'secrecy', } ``` >[danger] type: String 存儲為字符串 > enum 可枚舉類型,男 or 女 or 保密 > default 默認值為保密 ***** 2. 居住地類型建模 ![](https://box.kancloud.cn/aae62df21fb0100d9b1824f8f0581849_443x206.png) ``` // 居住地 residence: { // 字符串數組類型 type: [{type: String}] } ``` >[danger] 居住地,可以看出,前端傳過來的數據是一個數組,里面包含多個 > 所以設計為字符串數組類型 ***** 3. 行業選擇建模 ![](https://box.kancloud.cn/b9b2405c27a636242a56a3c15e58dbc7_395x179.png) ``` //行業 industry: { type: String } ``` ***** 4. 職業經歷建模 ![](https://box.kancloud.cn/651e9b15dbcdb6322b9dc1199fe1de20_744x203.png) ``` // 職業經歷 Career:{ type: [{ // 公司名稱 corporate: {type: String}, // 職位 job: {type: String} }] }, ``` ***** 5. 教育經歷建模 ![](https://box.kancloud.cn/cfeded8584d783cc075b1a2a3b863ad9_766x151.png) ``` // 教育經歷 experience: { type: [{ // 機構名稱 title: {type: String}, // 專業方向 major: {type: String}, // 學歷 enum: [1,2,3,4,5] 高中,本科,碩士,博士 Education: { type: Number, enum: [1,2,3,4,5]}, // 入學年份 enrollment_year: { type: Number}, // 畢業年份 graduation_year: {type: Number} }] } ```
                  <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>

                              哎呀哎呀视频在线观看