Last Sync: 2022-08-13 12:30:03
This commit is contained in:
parent
da7f55f2fc
commit
e597498fba
2 changed files with 21 additions and 37 deletions
|
@ -0,0 +1,21 @@
|
||||||
|
---
|
||||||
|
tags:
|
||||||
|
- Databases
|
||||||
|
- mongo_db
|
||||||
|
- node-js
|
||||||
|
- mongoose
|
||||||
|
---
|
||||||
|
|
||||||
|
# MongoDB: deleting a document from a collection
|
||||||
|
|
||||||
|
```js
|
||||||
|
|
||||||
|
async function deleteCourse(id) {
|
||||||
|
const result = await Course.deleteOne({id: id})
|
||||||
|
console.log(result)
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Use `findByIdAndRemove([id])` if you want to return the value that is deleted.
|
||||||
|
|
||||||
|
If we were to pass a query object that matches multiple documents in the database to `deleteOne` it would only delete the first document returned. To delete all use `deleteMany`.
|
|
@ -1,37 +0,0 @@
|
||||||
/* h1, h2, h3, h4, h5, h6, p {
|
|
||||||
font-family: 'Inter';
|
|
||||||
} */
|
|
||||||
|
|
||||||
/* pre, code {
|
|
||||||
font-family: 'JetBrains Mono' !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
code, code {
|
|
||||||
font-family: 'Jetbrains mono';
|
|
||||||
} */
|
|
||||||
/*
|
|
||||||
h1 {
|
|
||||||
|
|
||||||
font-size: 24px !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
h2 {
|
|
||||||
font-size: 20px !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
h3 {
|
|
||||||
font-size: 18px !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
h4 {
|
|
||||||
font-size: 16px !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
h5 {
|
|
||||||
font-size: 14px !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
p, ul, li, dl, dd, dt {
|
|
||||||
font-size: 14px;
|
|
||||||
} */
|
|
Loading…
Add table
Reference in a new issue