Mongodb Schema new fields wont be created when inserting new data

Viewed 10

i have a next.js application (using mongoose) with 2 Schemas/Models there. For example one of them is "Users", now i got few users that already made in the past but i want to make a new field, for example "posts", im trying to Insert a new line in the schema file like this:

posts: { type: Number, default: 1 }

now i got two problems and i have no idea how to fix them; a. i want to update all the current users (do i have to use a function that updates all?) b. when i insert new data it wont insert the new field.

0 Answers
Related