const serverS = await server.findOne({ guildID: message.guild.id });
serverS.settings[1]["links"] = true;
serverS.save()
The code I use ^^^^
So when it saves the changes I check the database using MongoDB compass I don’t see the change appearing in the array object
schema if needed to resolve problem
const ServerSchema = new mongoose.Schema({
guildID: { type: String },
settings: {
type: Array, default: [
{
//Some other stuff
},
{
links: false,
},
{
prefix: ",",
}
]
},
});
2
Answers
Found a way on how to update a part of a array using javascript and mongoose:
For example:
Saved Data:
The
save()
method returns a promise, so you shouldawait
the save as a following: