'Empty array is created instead of adding elements in it while using push function in mongoose

let configdb = await db.findOne({guildid: "test"});
                if (!configdb) {
                    await new db({guildid: "test", censor: {$push:{words: args[2]}}}).save();
                    return console.log("done");
                }
                await configdb.updateOne({censor:{$push:{words: args[2]}}});
                return console.log("done");

The value of args[2] is "test"

Here some variables which may seem undefined are already defined btw, this is a large code but i decided to put only the code where the database operation takes place. I already read many docs related to the $push function in mongoose, but here a small difference is that one of the object is the array instead of a variable, and I didn't get any error while the operation takes place in this code. Also it logged "done" which means the code worked like it was supposed except the part where it should add "test" to the array. So what exactly is bit wrong here?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source