第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

mongoose 的 population 的問題?

mongoose 的 population 的問題?

ibeautiful 2018-10-01 13:18:56
我有個 schema中 有如下一個變量:receiveComments:[{    whoComment:{      type:ObjectId,      ref:'Student'    },    whichHelp:{      type:ObjectId,      ref:"Help"    },    whichComment:{      type:ObjectId,      ref:"Comment"    }  }],其中的 whichComment 是用population 引用的 Comment schema的,是不是不能修改 whichComment 中的數(shù)據(jù)。比如:Comment schema 中有一個變量如下:have_saw:{      type:Boolean,      default:false     },現(xiàn)在我通過 whichComment 修改 have_saw 為true,然后保存,本地 mongodb 數(shù)據(jù)庫看不到對應(yīng)的數(shù)據(jù),但是下次輸出,這個值卻沒有改變,說明沒有保存成功,保存不了那個值?
查看完整描述

1 回答

?
波斯汪

TA貢獻1811條經(jīng)驗 獲得超4個贊

通常是可以修改的,例如:

1、pupulate得到相關(guān)聯(lián)的對象的值;

2、按照條件update相關(guān)聯(lián)的對象,類似于

.findOneAndUpdate({},{ $set : { }}, { new : true} , function (err, res){      if(err) {console.log(err)};
      console.log('Updated result is ' + res);

供參考。

Love MongoDB! Have Fun!


查看完整回答
反對 回復(fù) 2018-11-22
  • 1 回答
  • 0 關(guān)注
  • 507 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號