Update with mongoose is not working when there is a dot notation in one of the key names.
I am trying to update a document with mongoose which has the following structure:
{
"test": {
"directory": {
"testFile.js": {
"file": {
"contents": "test"
}
}
}
}
}
As you can see it includes a key name: 'testfile.js', this is causing an issue when I try to update the content of the file:
const updatedFileTree = await this.fileTree
.findByIdAndUpdate(
{ _id: id },
{
$set: {
'test.directory.testFile.js.file.contents': 'new value',
},
},
)
.exec();
return updatedFileTree;
Because it is already using dot notations, is there a way to make this work because I have to keep the structure I have right now (with dots).