MongoDB only register values that are Objects or Arrays

33 views Asked by At

I'm having some trouble when editing my MongoDB schema

When I first created the schema, it was like that:

const charSchema = new Schema(
    {
        name: String,
        playerUID: String,
    }
)

So, I've tried to made some changes and now it looks like this:

const charSchema = new Schema(
    {
        playerUID: String,
        name: {
            first: String,
            middle: String,
            last: String,
        },
        age: Number,
        race: String,
        title: String,
        classe: String,
        occupation: String,
        status: String,
    }
)

But now, when I try to make a post like this using Insomnia:

{
    "playerUID": "[email protected]",
    "name": {
        "first": "Jack",
        "middle": "Test",
        "last": "Jr"
    },
    "age": 24,
    "race":"Human",
    "title": "The blade",
    "classe": "Warrior",
    "occupation": "Guard",
    "status": "Alive"
}

It just returns me this:

{
playerUID: '[email protected]',
name: { first: 'Jack', middle: 'Test', last: 'Jr' },
race: [],
_id: new ObjectId(\"653558e68616671113c29b0a\"),
__v: 0\n
}

So, basically, all the things that aren't name and race aren't showing up, and the race info shows empty

I've already tried to create another model file, restar VSCode and Insomnia but i still with the same issue.

0

There are 0 answers