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: String09 }, { _id: false });10 mongoose.model('Address', AddressSchema);

Get Node.js, MongoDB, and AngularJS Web 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.