Changes from codemod
This commit is contained in:
@@ -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]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user