MongoDB is a database application that stores JSON documents (or records) that you can use in your application. Unlike SQL, another type of database, Mongo is a non-relational or "NoSQL" database. This means Mongo stores all associated data within one record, instead of storing it across many preset tables as in a SQL database.
Mongoose is a popular npm package that is often installed alongside Mongo. With Mongoose, you can use plain JavaScript objects instead of JSON, which makes it easier to work with Mongo. Also, it allows you to create blueprints for your documents called schemas, so you don't accidentally save the wrong type of data and cause bugs later.
In the MongoDB and Mongoose courses, you'll learn the fundamentals of working with persistent data including how to set up a model, and save, delete, and find documents in the database.
This is the boilerplate for the MongoDB and Mongoose lessons. Instructions for completing these lessons start at https://www.freecodecamp.org/learn/apis-and-microservices/mongodb-and-mongoose/
- Install and Set Up Mongoose
- Create a Model
- Create and Save a Record of a Model
- Create Many Records with model.create()
- Use model.find() to Search Your Database
- Use model.findOne() to Return a Single Matching Document from Your Database
- Use model.findById() to Search Your Database By _id
- Perform Classic Updates by Running Find, Edit, then Save
- Perform New Updates on a Document Using model.findOneAndUpdate()
- Delete One Document Using model.findByIdAndRemove
- Delete Many Documents with model.remove()
- Chain Search Query Helpers to Narrow Search Results