Closed jyang1003 closed 2 years ago
MERN
Invalid schema configuration: Model is not a valid type at path nutrition
Model
nutrition
const mongoose = require('mongoose') const Nutrition = require('./nutrition') const User = require('./user') const profileSchema = new mongoose.Schema({ name: { type: String, required: false }, height: { type: Number, required: false }, weight: { type: Number, required: false }, age: { type: Number, required: false }, baseCaloricMaintenence: { type: Number, required: false }, caloricGoal: { type: Number, required: false }, proteinGoal: { type: Number, required: false }, carbsGoal: { type: Number, required: false }, fatsGoal: { type: Number, required: false }, nutrition: Nutrition, owner: { // this links the user Id type: mongoose.Schema.Types.ObjectId, ref: 'User' } }) module.exports = mongoose.model('Profile', profileSchema)
Either something wrong with one of my schemas or routes
google, but most of the issues other people had are typos and i can't find any
The nutrition is linking to another schema right?
Nutrition is a subdoc of profile
Right but the owner of it links to user right?
Yeah it should
Fixed! Thanks Dori.
What stack are you using?
(ex: MERN(mongoose + react), DR(django + react), PEN, etc.)
MERN
What's the problem you're trying to solve?
Invalid schema configuration:
Model
is not a valid type at pathnutrition
Post any code you think might be relevant (one fenced block per file)
If you see an error message, post it here. If you don't, what unexpected behavior are you seeing?
What is your best guess as to the source of the problem?
Either something wrong with one of my schemas or routes
What things have you already tried to solve the problem?
google, but most of the issues other people had are typos and i can't find any