O'Reilly logo

Learning Node.js for .NET Developers by Harry Cummings

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required