在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問答/數(shù)據(jù)庫  HTML/ mongoose, mongodb db.collection.find()語

mongoose, mongodb db.collection.find()語法傳入query方式問題

// 這種傳query的方式可以拿到數(shù)據(jù) 
router.get("/cartList", (req, res, next) => {
  User.findOne({ userId: '123456' }, (err, doc) => { });
}

// 這種傳query的方式不能拿到數(shù)據(jù)
router.get("/cartList", (req, res, next) => {
  let userId = req.cookies.userId
  console.log(userId)
  User.findOne({ userId: userId }, (err, doc) => { });
}

第二種方式userId也成功打出了, 并且是String類型
這是為什么呢?

回答
編輯回答
毀了心

是req.session吧

2017年5月6日 15:51
編輯回答
維他命

貼出你的 schema 看看,是怎樣寫的,理論上,這兩種寫法沒什么區(qū)別.
既然沒報錯,那說明,語法是沒問題的.是不是,數(shù)據(jù)庫本來就沒有對應(yīng)的數(shù)據(jù)?

2017年4月12日 01:58
編輯回答
檸檬藍

這么神奇,console.log(userId==='123456')看看

2017年11月7日 15:41