Sorry for my poor english, I hope you understand what I mean.
I have a mongoDb database with many tables. In my table "Files" all the records has a field called "etiquetas". This field is an array of strings. I want to update this field (in a the record with id XXXX) inserting new strings. I have read the docs of mongoose and I have tried to update a record using "push" function, but mongoose its inserting an object and not a string into the array "etiquetas".
Let me show you whats is happening. This is whats Im doing to update the record (in a nodejs app):
let exampleString = "61c43b346c6168d039f8c0gg"; // Using an example string
await File.updateOne(
{ id: fileId },
{ $push: { etiquetas: { exampleString } } }
);
And this is what is happening (I have inserted manually the first record of the array "etiquetas"):
Try to remove the curly braces surrounding the exampleString
:
let exampleString = "61c43b346c6168d039f8c0gg"; // Using an example string
await File.updateOne(
{ id: fileId },
{ $push: { etiquetas: exampleString } }
);