Logo
BlogToast.
HomeAll PostsCategoriesRandom
Sign in
Logo
BlogToast.

Discover stories, insights, and perspectives from writers around the world.

Explore

  • All posts
  • Categories
  • Random

Dashboard

  • Sign in
  • Sign up
  • Forgot password

Legal

  • Contact
  • Privacy policy
  • Terms of service

© 2026 BlogToast. All rights reserved.

MissingSchemaError: Schema hasn't been registered for model
Technology7 min read

MissingSchemaError: Schema hasn't been registered for model

N

N@rutO

August 15, 2024

Are you deploying a nextjs app ? and faced this issue ?

Application error: a server-side exception has occurred (see the server logs for more information).

Digest: 4231503238.

When you check the logs you find that it is a schema error.

MissingSchemaError: Schema hasn't been registered for model "Category". Use mongoose.model(name, schema).

const blogs = await Blog.find({}).populate("author category");

This is caused by mongoose not finding model when populating the data.

Here is the fix.

Import your schema (model) to where it is being used.

import "@/database/category.model"
import "@/database/auth.model"

Basically, The NextJS page that is getting data from the server with getServerSideProps via database call needs to have the referenced model file imported.

This way by importing the file containing the referenced model at the top of your page file you are registering the model before you use it down below inside getServerSideProps.

Tags

deploy next mongodb schema error
Advertisement

Discussion (0)

Related Blogs

Explore similar articles

Fix High CPU usage (winlogui.exe)
Technology
3 min

Fix High CPU usage (winlogui.exe)

J

N@rutO

Aug 14

3 0
How to Buy a Domain in Nepal: A Step-by-Step Guide
Technology
4 min

How to Buy a Domain in Nepal: A Step-by-Step Guide

Buying a domain in Nepal is the first step to establishing your online presence. Whether you choose a free .np domain or a paid international domain like .com, the process is simple and accessible. This guide explains the types of domains available in Nepal and walks you through the steps to register the perfect domain for your website or business.

N

bmasmhj

Dec 18

2 0