.env.local example
1MONGODB_URI=mongodb+srv://username:pass@cluster0.asdfg.mongodb.net/
models/customerModel.js
1import mongoose, { Schema } from "mongoose";
2
3 const customerSchema = new Schema(
4 {
5 email: {
6 type: String,
7 required: true,
8 unique: true,
9 match: /^[^s@]+@[^s@]+.[^s@]+$/,
10 },
11 },
12 {
13 timestamps: true,
14 }
15 );
16
17 const Customer =
18 mongoose.models.Customer || mongoose.model("Customer", customerSchema);
19
20 export default Customer;