Changes from codemod

This commit is contained in:
2026-04-21 21:35:59 +04:00
parent e7bc8790b1
commit b532981404
8 changed files with 689 additions and 569 deletions
@@ -21,7 +21,9 @@ module.exports = createCoreController('api::commentaire.commentaire', ({strapi})
throw new UnauthorizedError(ctx, err, 'Opération non autorisée')
}
}
const user = await strapi.entityService.findOne('plugin::users-permissions.user', body.data.user.id)
const user = await strapi.documents('plugin::users-permissions.user').findOne({
documentId: "__TODO__"
})
if (!user) {
throw new NotFoundError('Utilisateur introuvable.')
@@ -33,7 +35,8 @@ module.exports = createCoreController('api::commentaire.commentaire', ({strapi})
data.user = user.id
const parole = await strapi.entityService.findOne('api::parole.parole', data.parole, {
const parole = await strapi.documents('api::parole.parole').findOne({
documentId: "__TODO__",
fields: ['id']
})
@@ -41,13 +44,15 @@ module.exports = createCoreController('api::commentaire.commentaire', ({strapi})
throw new NotFoundError('Texte introuvable.')
}
const newCommentaire = await strapi.entityService.create('api::commentaire.commentaire', {
const newCommentaire = await strapi.documents('api::commentaire.commentaire').create({
data: {
...data
}
})
await strapi.entityService.update('api::parole.parole', parole.id, {
await strapi.documents('api::parole.parole').update({
documentId: "__TODO__",
data: {
commentaires: [newCommentaire.id]
}