Beginner of Node.js and MongoDB. I just wondering why there is no "isAdmin" in my MongoDB and how to fix it? Thank you~
import mongoose from "mongoose";
const UserSchema = new mongoose.Schema(
{
username: {
type: String,
required: true,
unique: true,
},
email: {
type: String,
required: true,
unique: true,
},
password: {
type: String,
required: true,
},
isAdmin: {
type: Boolean,
required: false,
},
},
{ timestamps: true }
);
export default mongoose.model("User", UserSchema);
The user at database is without "isAdmin" like this:
username: "johnAdmin"
email: "johnAdmin@gmail.com"
password: "$2a$10$pjuVsWEe8BhP0nvgNcjS3eSp0vKwyzDUZNGDf5nYn3/Rn2yunh.iy"
createdAt: 2022-11-05T21:44:42.402+00:00
updatedAt: 2022-11-05T21:44:42.402+00:00
I have tried to change "required"
to true
, but it still does not work.