Adding the new collections

Open your MongoDB shell and execute the following:

  use OrderBase;
  db.createCollection('User');
  db.createCollection('Role');
  db.createCollection('AccessToken');

This will create the necessary collections that we need to store users and their roles and tokens. The new documents will have the following structure:

User:
{
    firstName,
    lastName,
    email,
    roleID,
    password
}

For now, we will not add any users or tokens (this comes later when we extend the API), but we will add the roles that we are going to use. To keep it simple, we will just have two of them:

  • Producer: This is the user who sells goods in the shop and who can add additional products to it.
  • Customer: This is the user who buys things from the shop and who can create ...

Get Learning Node.js for Mobile Application Development 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.