From e597498fba4589ff0a3e3e546d453eebc7c914f6 Mon Sep 17 00:00:00 2001 From: tactonbishop Date: Sat, 13 Aug 2022 12:30:03 +0100 Subject: [PATCH] Last Sync: 2022-08-13 12:30:03 --- Databases/MongoDB/Deleting_documents.md | 21 ++++++++++++++ markdown-styles.css | 37 ------------------------- 2 files changed, 21 insertions(+), 37 deletions(-) delete mode 100644 markdown-styles.css diff --git a/Databases/MongoDB/Deleting_documents.md b/Databases/MongoDB/Deleting_documents.md index e69de29..6cadf3a 100644 --- a/Databases/MongoDB/Deleting_documents.md +++ b/Databases/MongoDB/Deleting_documents.md @@ -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`. \ No newline at end of file diff --git a/markdown-styles.css b/markdown-styles.css deleted file mode 100644 index f6dda6d..0000000 --- a/markdown-styles.css +++ /dev/null @@ -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; -} */