Defining the Order Schema

Next, you need to create the order schema to keep track of the items ordered, shipping information, and billing information. Listing 28.5 implements the OrderSchema model, which stores the necessary information about the order. Notice that a Date type is assigned to the timestamp field to keep track of when the order was placed. Also, the items field is an array of ProductQuantitySchema subdocuments.

Listing 28.5 cart_model.js-OrderSchema: Defining the order schema to store the order information


33 var OrderSchema = new Schema({
34   userid: String,
35   items: [ProductQuantitySchema],
36   shipping: [AddressSchema],
37   billing: [BillingSchema],
38   status: {type: String, default: "Pending"},
39   timestamp: { type: Date, default: Date.now }
40 });
41 mongoose.model('Order', OrderSchema);


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

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