Defining the Address Schema

You begin by defining an address schema that will be generic so that it can be used in the shipping information and as part of the billing information. Listing 28.1 implements AddressSchema, which contains the standard address information. Notice that the following code is used to disable the _id property since you do not need to look up addresses by ID:

{ _id: false }

Listing 28.1 cart_model.js-AddressSchema: Defining an address schema for shipping and billing


03 var AddressSchema = new Schema({
04   name: String,
05   address: String,
06   city: String,
07   state: String,
08   zip: String
09 }, { _id: false });
10 mongoose.model('Address', AddressSchema);


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

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