The next step is getting our users from the database. As we said, we are not going to create a registration method, so we will need to insert at least one user manually. You can log in to the webshop database using Robomongo. Right-click on Collections and choose Create collection.... Name your new collection user. Now, you can right-click on the user collection and pick Insert Document.... The document you are going to insert is just a JavaScript object, so enter some object with the username and password properties:
You can now browse the newly inserted document(s):
We can now query the database from Node and check for a user with the given username and password. To connect with MongoDB, we are going to use the Node.js MongoDB API Mongoose (http://mongoosejs.com/). As always, we can install Mongoose with npm:
npm install mongoose --save
After that, using...