Defining the Customer, Product, and Orders Models

You should always look at the object model needs as the first step in implementing an application. In this example, the goal is to provide a shopping cart. To do so, you need a customer model as a container for the shopping cart. Also, you need products to place into the shopping cart. To check out, you need billing information and shipping information, and then once the order is placed, you need a way to store the order. Therefore, you need a model for the customer, product, order billing, and shipping data to support the shopping cart.

The following sections discuss the design of each of the model schemas implemented in the project. The schemas are all contained in a file named cart_model.js that implements all the schemas. You need to load the mongoose library’s Schema object:

01 var mongoose = require('mongoose'),
02     Schema = mongoose.Schema;

The following sections describe the rest of the code you need to use to implement this example. The full schema definition can be viewed in Listing 28.7.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.223.33.157