Welcome, Unlock the world of Schema and Model in our MERN app! π This tutorial introduces you to the core concepts, guiding you through the creation of a Registration Schema and the building of a Model.
const mongoose = require("mongoose");
// Define the User schema
const userSchema = new mongoose.Schema({
username: {
type: String,
required: true,
},
email: {
type: String,
required: true,
},
phone: {
type: String,
required: true,
},
password: {
type: String,
required: true,
},
isAdmin: {
type: Boolean,
default: false,
},
});
// define the model or the collection name
export const User = new mongoose.model("USER", userSchema);