Using MongoDB with Express
The games service module in our application currently stores all its data in memory. This worked well enough for demo purposes, but isn't suitable for a real application. We lose all the data whenever the application restarts. It also prevents us from scaling our application across multiple processes. Each instance would have its own game service with different data. Users would see different data depending on which server happened to handle their request.
We're going to update our games service to store its data in MongoDB. For this, we're going to make use of a library called Mongoose.
Persisting objects with Mongoose
Recall that, unlike a relational database, MongoDB does not require documents in the same collection ...
Get Learning Node.js for .NET Developers now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.