So I have this code here
const quoteRanking = await quoteRankingSchema.findOne({});
if (!quoteRanking) {
return await new quoteRankingSchema({
guilds: [
{
id: guild.id,
quotes: [
{
messageId: msg.id,
stars: 0
}
]
}
]
}).save();
};
await quoteRankingSchema.findOneAndUpdate(
{
'guilds.id': guild.id
},
{
$push: {
'guilds.quotes': { 'messageId': msg.id, 'stars': 0 }
}
}
);
/*
quoteRankingSchema: {
guilds: [
{
id: '12345',
quotes: [
{
messageId: '12345',
stars: 0
},
...
]
},
...
]
}
*/
And I get this err: “err: MongoServerError: Plan executor error during findAndModify :: caused by :: Cannot create field ‘quotes’ in element {guilds: [ { id: “1066352952983433317”, quotes: [ { messageId: “1146123009380331640”, stars: 0 } ] } ]}”.
I searched on google how to do it an in every example they do the same thing, but mine ain’t working