当前位置:网站首页>UnhandledPromiseRejectionwarning:CastError: Cast to ObjectId failed for value
UnhandledPromiseRejectionwarning:CastError: Cast to ObjectId failed for value
2022-04-23 20:30:00 【Different 213】
UnhandledPromiseRejectionwarning:CastError: { One of the solutions }
- Cause of error : I want to query the corresponding in the database id, Delete data . But the result is an error .
The error message is :UnhandledPromiseRejectionwarning:CastError: Cast to ObjectId failed for value " 5ffbb96755245c37047691fa" at path “_id” for model "User
-
My mistake is
req.query.idThe output is the same as what I entered manually id Have the same value , But usefindOne()The method is to query the corresponding data in the database . Then take a closer look at the terminal display , The discovery may be due to spaces . -
because
req.query.idThere is an error caused by blank space in the print result of .
As shown below, the terminal displays spaces :

The following code is used to test and draw a conclusion :
if (req.query.id.trim() === '5ffbb8e355245c37047691f4') {
console.log(' Results the same ')
} else {
console.log(req.query.id)
}
trim()Method , Remove the spaces on both sides of the string . The output result is :” Results the same “.
版权声明
本文为[Different 213]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204210550451013.html
边栏推荐
- How can matlab obtain the truncated image in trainingimagelabeler
- 打新债中签以后怎么办,网上开户安全吗
- Numpy sort search count set
- Modeling based on catiav6
- Plato farm is one of the four largest online IEOS in metauniverse, and the transaction on the chain is quite high
- Why does ES6 need to introduce map when JS already has object type
- Latest investigation and progress of building intelligence based on sati
- Rt-1052 learning notes - GPIO architecture analysis
- Paper writing 19: the difference between conference papers and journal papers
- 16MySQL之DCL 中 COMMIT和ROllBACK
猜你喜欢

Linux64Bit下安装MySQL5.6-不能修改root密码

SQL Server Connectors By Thread Pool | DTSQLServerTP plugin instructions

DNS cloud school | quickly locate DNS resolution exceptions and keep these four DNS status codes in mind

DNS cloud school | analysis of hidden tunnel attacks in the hidden corner of DNS

Leetcode 994, rotten orange

Monte Carlo py solves the area problem! (save pupils Series)

Sqoop imports tinyint type fields to boolean type

CVPR 2022 | querydet: use cascaded sparse query to accelerate small target detection under high resolution

【PTA】L1-002 打印沙漏

Commit and rollback in DCL of 16 MySQL
随机推荐
Zdns was invited to attend the annual conference of Tencent cloud basic resources and share the 2020 domain name industry development report
Go zero framework database avoidance Guide
LeetCode 116. 填充每个节点的下一个右侧节点指针
SQL: query duplicate data and delete duplicate data
Thirty What are VM and VC?
Solve the Chinese garbled code of URL in JS - decoding
Leetcode 1346. Check whether integers and their multiples exist
[PTA] l1-002 printing hourglass
The market share of the financial industry exceeds 50%, and zdns has built a solid foundation for the financial technology network
Sqoop imports data from Mysql to HDFS using lzop compression format and reports NullPointerException
Analysis of the relationship between generalized Bim and CAD under the current background
LeetCode 1337、矩阵中战斗力最弱的 K 行
【PTA】L1-002 打印沙漏
Actual measurement of automatic ticket grabbing script of barley network based on selenium (the first part of the new year)
PostgreSQL basic functions
BMP JPEG picture to vector image contourtrace
DNS cloud school rising posture! Three advanced uses of authoritative DNS
Modeling based on catiav6
论文写作 19: 会议论文与期刊论文的区别
How to configure SSH public key in code cloud