Book Image

Learning Node.js for Mobile Application Development

Book Image

Learning Node.js for Mobile Application Development

Overview of this book

Table of Contents (21 chapters)
Learning Node.js for Mobile Application Development
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
14
Creating an E-Commerce Application Using the Ionic Framework
Index

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 orders and retrieve information about products as well as orders that were created by the current user.

It is understood that default ObjectID generated by MongoDB will be included in the preceding code. For the access token...