Cannot overwrite mongoose model once compiled with Nextjs || mongodb

preview_player
Показать описание

Рекомендации по теме
Комментарии
Автор

Thank you. i was frustrated and was restarting my nextjs server again again. Thank you

aquib
Автор

you're a life saver dude.. thanks alot!

aaronsanki
Автор

import { Schema, model, models } from "mongoose";

const Twofa = models?.Twofa || model("Twofa", TwofaSchema);

NOTE: `Twofa` in the above example must be used all through. Changing to something like this can lead to the error:

# WRONG
const Twofa = models?.Twofa || model("TwoFactorAuthentication", TwofaSchema);

# RIGHT
const Twofa = models?.Twofa || model("Twofa", TwofaSchema);

NewAwesomeTech
Автор

BRO YOU SAVED MY LIFE. THANKS SO MUCH!!!

lOmaine
Автор

I've been searching this crap for 2 days, thank you! 😂

andreluizcostamarques
Автор

thank you for you video. it solves my issue

go-next
Автор

Cool but Im having problems using this with typescript

YOUdudex
Автор

same error is occuring after trying this method.

animishshrivant
welcome to shbcf.ru