Summary
NoSQL databases are a powerful alternative to “traditional” relational ones. MongoDB is arguably the best known of the NoSQL databases in use today, and it works with documents encoded in a JSON variant. Using a document-based database such as MongoDB allows developers to use more flexible, loosely-structured data models and can improve iteration time in a fast-moving project.
The well known Mongoose library is an adaptor for MongoDB that works in Node.js and that abstracts quite a lot of complexity when it comes to querying and saving operations.
Over this chapter we’ve covered quite some aspects of working with Mongoose and Nest.js, like:
- How to start up a local MongoDB instance with Docker Compose.
- How to import the @nestjs/mongoose module in our root module and connect to our MongoDb instance.
- What are schemas and how to create one for modelling our data.
- Setting up a pipeline that allows us to write to and read from our MongoDB database as a reaction...