250x250
Notice
Recent Posts
Recent Comments
- Today
- Total
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | |||
| 5 | 6 | 7 | 8 | 9 | 10 | 11 |
| 12 | 13 | 14 | 15 | 16 | 17 | 18 |
| 19 | 20 | 21 | 22 | 23 | 24 | 25 |
| 26 | 27 | 28 | 29 | 30 |
Tags
- moment
- await
- TailwindCSS
- single quote
- certbot
- Express
- til
- css
- nginx
- double quote
- JavaScript
- TypeScript
- async
- flutter
- findByIdAndDelete
- Nodejs
- clipBehavior
- wil
- atlas
- mongodb
- jsonwebtoken
- Node.js
- MYSQL
- EC2
- mongoose
- https
- RDS
- sequelize
- Find
- AWS
Link
Archives
기억 휘발 방지소
[Node.js / mongoose] findByIdAndDelete로 삭제 본문
728x90
반응형
findByIdAndDelete()에 매개변수로는 id값이 들어온다. 몽고DB에 _id값
findOneAndDelete({ _id: id })를 줄인 버전이라고 할 수 있다.
export const deletePost = async (req, res) => {
const { id } = req.params;
await Post.findByIdAndDelete(id);
return res.redirect("/");
};728x90
반응형
'Database > ODM' 카테고리의 다른 글
| [Node.js / Mongoose] 데이터 삭제하기 (0) | 2021.10.04 |
|---|---|
| [Node.js / mongoose] populate() (0) | 2021.09.28 |
| [Node.js / mongoose] findByIdAndUpdate로 수정을 해보자 (0) | 2021.09.21 |
| [Node.js / mongoose] findOne, findById로 검색을 해보자 (0) | 2021.09.20 |
| [Node.js / mongoose] mongoDB에 저장을 해보자 (0) | 2021.09.20 |