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

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1beb3a7-31a49.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1beb3a7-31a49.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?