Fix typo artiste lifecycles
This commit is contained in:
+10
-7
@@ -8,34 +8,37 @@
|
|||||||
const slugify = require('slugify')
|
const slugify = require('slugify')
|
||||||
|
|
||||||
const jwennTeksEpiId = async data => {
|
const jwennTeksEpiId = async data => {
|
||||||
const teks = await strapi.query('paroles').find({id_in: data})
|
const teks = await strapi.db.query('api::parole.parole').find({id_in: data})
|
||||||
return teks
|
return teks
|
||||||
}
|
}
|
||||||
|
|
||||||
const jwennAwtisEpiId = async id => {
|
const jwennAwtisEpiId = async id => {
|
||||||
const artiste = await strapi.query('artiste').find({id})
|
const artiste = await strapi.db.query('api::artiste.artiste').findOne({id})
|
||||||
return artiste
|
return artiste
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
beforeUpdate: async event => {
|
beforeUpdate: async event => {
|
||||||
let {data} = event
|
console.log('event', event)
|
||||||
|
let {data} = event.params
|
||||||
|
|
||||||
if (!data.slug) {
|
|
||||||
|
if (!data.slug || data.slug !== slugify(data.alias, {lower: true, remove: /[*#+~.()'"!:@]/g})) {
|
||||||
data.slug = slugify(data.alias, {lower: true, remove: /[*#+~.()'"!:@]/g})
|
data.slug = slugify(data.alias, {lower: true, remove: /[*#+~.()'"!:@]/g})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
beforeCreate: async event => {
|
beforeCreate: async event => {
|
||||||
let {data} = event
|
let {data} = event.params
|
||||||
|
|
||||||
data.slug = slugify(data.alias, {lower: true, remove: /[*#+~.()'"!:@]/g})
|
data.slug = slugify(data.alias, {lower: true, remove: /[*#+~.()'"!:@]/g})
|
||||||
},
|
},
|
||||||
afterUpdate: async event => {
|
afterUpdate: async event => {
|
||||||
let {data} = event
|
console.log('event', event)
|
||||||
|
let {data} = event.params
|
||||||
const {id} = data
|
const {id} = data
|
||||||
const artiste = await jwennAwtisEpiId(id)
|
const artiste = await jwennAwtisEpiId(id)
|
||||||
|
|
||||||
if (artiste.teks && artiste.paroles.length >= 1) {
|
if (artiste.paroles && artiste.paroles.length >= 1) {
|
||||||
const paroles = await jwennTeksEpiId(artiste.paroles)
|
const paroles = await jwennTeksEpiId(artiste.paroles)
|
||||||
Promise.all(paroles.map(async t => {
|
Promise.all(paroles.map(async t => {
|
||||||
const {id, tit, slug, artiste} = t
|
const {id, tit, slug, artiste} = t
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
"name": "Apache 2.0",
|
"name": "Apache 2.0",
|
||||||
"url": "https://www.apache.org/licenses/LICENSE-2.0.html"
|
"url": "https://www.apache.org/licenses/LICENSE-2.0.html"
|
||||||
},
|
},
|
||||||
"x-generation-date": "2022-05-12T15:07:13.371Z"
|
"x-generation-date": "2022-05-12T15:51:28.188Z"
|
||||||
},
|
},
|
||||||
"x-strapi-config": {
|
"x-strapi-config": {
|
||||||
"path": "/documentation",
|
"path": "/documentation",
|
||||||
|
|||||||
Reference in New Issue
Block a user