Ordered by and for customer

To record the details of the customer who the order is meant for, we will add customer_name and customer_email fields to the Order schema.

mern-marketplace/server/models/order.model.js:

customer_name: { type: String,  trim: true, required: 'Name is required' },customer_email: { type: String, trim: true,    match: [/.+\@.+\..+/, 'Please fill a valid email address'],    required: 'Email is required' }

To reference the signed-in user who placed the order, we will add an ordered_by field.

mern-marketplace/server/models/order.model.js:

ordered_by: {type: mongoose.Schema.ObjectId, ref: 'User'}

Get Full-Stack React Projects 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.