diff --git a/src/api/artiste/content-types/artiste/lifecycles.js b/src/api/artiste/content-types/artiste/lifecycles.js index 38087d2..2aaf308 100644 --- a/src/api/artiste/content-types/artiste/lifecycles.js +++ b/src/api/artiste/content-types/artiste/lifecycles.js @@ -8,8 +8,8 @@ const slugify = require('slugify') const jwennTeksEpiId = async data => { - const teks = await strapi.db.query('api::parole.parole').find({id_in: data}) - return teks + const paroles = await strapi.db.query('api::parole.parole').find({id_in: data}) + return paroles } const jwennAwtisEpiId = async id => { @@ -40,14 +40,14 @@ module.exports = { if (artiste.paroles && artiste.paroles.length >= 1) { const paroles = await jwennTeksEpiId(artiste.paroles) Promise.all(paroles.map(async t => { - const {id, tit, slug, artiste} = t + const {id, titre, slug, artiste} = t const alias = artiste.map(a => a.alias).join('-') - const slugUpdated = slugify(`${alias}-${tit}`, {lower: true, remove: /[*#+~.()'"!:@]/g}) + const slugUpdated = slugify(`${alias}-${titre}`, {lower: true, remove: /[*#+~.()'"!:@]/g}) + if (slug !== slugUpdated) { - await strapi.query('paroles').update( - {id}, - {slug: slugUpdated} - ) + await strapi.db.query('api::parole.parole').update({ + where: {id, slug: slugUpdated} + }) } })) }