WDI-SEA / project-4-issues

Open an issue to receive help on project 4 issues
0 stars 0 forks source link

Model issues #12

Closed jyang1003 closed 2 years ago

jyang1003 commented 2 years ago

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 path nutrition

Post any code you think might be relevant (one fenced block per file)

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)

If you see an error message, post it here. If you don't, what unexpected behavior are you seeing?

Screen Shot 2022-01-10 at 1 39 30 PM

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

DoireannJane commented 2 years ago

The nutrition is linking to another schema right?

jyang1003 commented 2 years ago

Nutrition is a subdoc of profile

DoireannJane commented 2 years ago

Right but the owner of it links to user right?

jyang1003 commented 2 years ago

Yeah it should

jyang1003 commented 2 years ago

Fixed! Thanks Dori.