System Information
- Strapi Version: 3.3.3
- Database: Mongodb
Hello! I have a documents
field in my user model, wich is a repeatable components with some fields (string, number, and file).
When i want to add a document to this user, i have to fetch this user to get all his documents, map them to give to Strapi the expected format, and then update him with a new array of all mapped documents and the new one.
I’m in a plugin controller.
const user = await strapi.plugins[userPluginName].services.user.fetch({ id: idToUpdate });
const documents = user.documents.map((doc) => mapDocument(doc));
await strapi.plugins[userPluginName].services.user.edit(
{
id: idToUpdate,
},
{ documents: [...documents, document] }
);
Is there a simple way to add a new document to this user without having to fetch him and spread its existing documents?
Thanks!