fix: remove deprecated `remove` method (#4924)

pull/4858/merge
Rishiraj S 10 months ago committed by GitHub
parent d4436e8a8f
commit 49ba524c15
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      src/data/roadmaps/mongodb/content/102-collections/104-delete-methods.md

@ -30,20 +30,6 @@ db.users.deleteMany({ country: 'Australia' });
This command will delete all `users` documents with a `country` field equal to `"Australia"`.
## db.collection.remove()
The `remove()` method can be used to delete documents in a more flexible way, as it takes both a filter and a `justOne` option. If `justOne` is set to true, only the first document (by natural order) that matches the filter will be removed. Otherwise, if `justOne` is set to false, all documents matching the filter will be deleted.
Syntax: `db.collection.remove(FILTER, JUST_ONE)`
Example:
```javascript
db.users.remove({ age: { $lt: 18 } }, true);
```
This command would delete a single user document with an `age` field value less than 18.
## db.collection.drop()
In cases where you want to remove an entire collection, including the documents and the metadata, you can use the `drop()` method. This command does not require a filter, as it removes everything in the specified collection.

Loading…
Cancel
Save