11 - Delete Many Documents with model.remove() - MongoDB and Mongoose - freeCodeCamp Tutorial
Channel: Ganesh H
Date: 2020-07-13

Instead of deleting one record, we can destory all the documents that match a specific criteria, using the model's remove() method. This is useful for performing bulk deletions.

Link to challenge : https://www.freecodecamp.org/learn/apis-and-microservices/mongodb-and-mongoose/delete-many-documents-with-model-remove
Written Guide : https://www.notion.so/ganeshh123/Delete-Many-Documents-with-model-remove-8c76ef50c15e496ebf32ae5f2fd36ccd

Full Playlist for this course : https://www.youtube.com/playlist?list=PLhGp6N0DI_1QJMb63oecYZ3lLjrF4PnIs
All Writen Guides for this course : https://www.notion.so/ganeshh123/6f987e7260914612b06adf840dbb00c3
All My Tutorials can be found at : https://www.notion.so/Tutorials-Ganesh-H-293ea420d34a464f9a1907e0405b5f26

Concepts:
model.remove()
Removes all documents that match conditions from the collection. To remove just the first document that matches conditions, set the single option to true.
https://mongoosejs.com/docs/api/model.html#model_Model.remove

$gte
$gte selects the documents where the value of the field is greater than or equal to a specified value (e.g. value.)
https://docs.mongodb.com/manual/reference/operator/query/gte/

Model
Models are fancy constructors compiled from Schema definitions. An instance of a model is called a document. Models are responsible for creating and reading documents from the underlying MongoDB database.
https://mongoosejs.com/docs/models.html

-————————————————————————————————————-
MongoDB is a cross-platform document-oriented database program. Classified as a NoSQL database program, MongoDB uses JSON-like documents with optional schemas. MongoDB is developed by MongoDB Inc. and licensed under the Server Side Public License (SSPL).

Mongoose is an Object Data Modeling (ODM) library for MongoDB and Node.js. It manages relationships between data, provides schema validation, and is used to translate between objects in code and the representation of those objects in MongoDB.

freeCodeCamp (also referred to as “Free Code Camp”) is a non-profit organization that consists of an interactive learning web platform, an online community forum, chat rooms, online publications and local organizations that intend to make learning web development accessible to anyone. Beginning with tutorials that introduce students to HTML, CSS and JavaScript, students progress to project assignments that they complete either alone or in pairs. Upon completion of all project tasks, students are partnered with other nonprofits to build web applications, giving the students practical development experience.

Thanks for Watching!