Image of the error displayed on client-side screen
Below is the code in the user.model.ts file.
import mongoose from "mongoose";
export interface TUser extends mongoose.Document {
username: string;
email: string;
password: string;
watchlist: string[];
isVerified: boolean;
verifyCode: string;
verifyCodeExpiry: Date;
}
const userSchema = new mongoose.Schema<TUser>(
{
username: {
type: String,
required: [true, "Username is required"],
unique: true,
},
email: {
type: String,
required: [true, "Email is required"],
},
password: {
type: String,
required: [true, "Password is required"],
},
watchlist: {
type: [String],
},
isVerified: {
type: Boolean,
default: false,
},
verifyCode: {
type: String,
},
verifyCodeExpiry: {
type: Date,
},
},
{ timestamps: true }
);
const User =
(mongoose.models["User"] as mongoose.Model<TUser>) ||
mongoose.model<TUser>("User", userSchema);
export default User;
My mongoDb cluster is running fine without any pauses and the connection string is also correct.
Please help me with this error.I have been trying to solve it for 2 days.
The application was running fine 2 days ago but suddenly this error popped up.
New contributor
Jenish P is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.