We can use the findOneAndRemove() or findByIdAndRemove() to destroy or delete records that match certain criteria. We get returned the deleted record in the form of an object.
Link to challenge : https://www.freecodecamp.org/learn/ap...
Written Guide : https://www.notion.so/ganeshh123/Dele...
Full Playlist for this course : • MongoDB and Mongoose - freeCodeCamp
All Writen Guides for this course : https://www.notion.so/ganeshh123/6f98...
All My Tutorials can be found at : https://www.notion.so/Tutorials-Ganes...
Concepts:
model.findByIdAndRemove()
Issue a mongodb findAndModify remove command by a document's _id field. findByIdAndRemove(id, ...) is equivalent to findOneAndRemove({ _id: id }, ...). Finds a matching document, removes it, passing the found document (if any) to the callback.
https://mongoosejs.com/docs/api/model...
model.findOneAndRemove()
Issue a mongodb findAndModify remove command. Finds a matching document, removes it, passing the found document (if any) to the callback.
https://mongoosejs.com/docs/api/model...
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!
Смотрите видео 10 - Delete One Document with model.findByIdAndRemove - MongoDB and Mongoose - freeCodeCamp Tutorial онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь Ganesh H 13 Июль 2020, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 4,614 раз и оно понравилось 40 людям.