The problem of how mongoose, mongodb db.collection.find () syntax is introduced into query

// query 
router.get("/cartList", (req, res, next) => {
  User.findOne({ userId: "123456" }, (err, doc) => { });
}

// query
router.get("/cartList", (req, res, next) => {
  let userId = req.cookies.userId
  console.log(userId)
  User.findOne({ userId: userId }, (err, doc) => { });
}

the second method, userId, is also successfully typed, and it is of String type
Why?

Mar.02,2021

is req.session


post your schema to see how it is written. In theory, there is no difference between the two methods.
since there is no error, it means that the grammar is fine. Is it true that there is no corresponding data in the database?


is this amazing, console.log (userId='123456') look at

Menu