Next.js Discord

Discord Forum

Mongoose MongoDB error

Unanswered
Brown bear posted this in #help-forum
Open in Discord
Brown bearOP
So I was building this simple app for which I chose mongoose. I used the next js examples to make this but getting some error in models file

What could be the possible reason



import mongoose from "mongoose"; export interface Quotes extends mongoose.Document { who: string; what: string; } const QuoteSchema = new mongoose.Schema<Quotes>({ who: { type: String, required: [true, "Quoter is required"], maxlength: [24, "Max lenght reached"], }, what: { type: String, required: [true, "Quote is required"], maxlength: [24, "Max lenght reached"], }, }); let Quote; if (mongoose.models.Quote){ Quote = mongoose.models.Quote } else { Quote = mongoose.model<Quotes>("Quote", QuoteSchema) } export default Quote;

1 Reply

Brown bearOP
this is the error