Replace _id by id
This commit is contained in:
@@ -20,7 +20,7 @@ module.exports = {
|
||||
let {data} = parseMultipartData(ctx)
|
||||
const awtis = await searchAwtis(data.alias)
|
||||
if (awtis) {
|
||||
entity = await strapi.services.awtis.update({_id: awtis._id}, awtis)
|
||||
entity = await strapi.services.awtis.update({id: awtis.id}, awtis)
|
||||
} else {
|
||||
data.published_at = null
|
||||
entity = await createStrapi.services.awtis.create(data)
|
||||
@@ -29,7 +29,7 @@ module.exports = {
|
||||
let {body} = ctx.request
|
||||
const awtis = await searchAwtis(body.alias)
|
||||
if (awtis) {
|
||||
entity = await strapi.services.awtis.update({_id: awtis._id}, awtis)
|
||||
entity = await strapi.services.awtis.update({id: awtis.id}, awtis)
|
||||
} else {
|
||||
body.published_at = null
|
||||
entity = await strapi.services.awtis.create(body)
|
||||
|
||||
@@ -19,12 +19,12 @@ module.exports = {
|
||||
if (values.teks && values.teks.length >= 1) {
|
||||
const teks = await jwennTeksEpiId(values.teks)
|
||||
Promise.all(teks.map(async t => {
|
||||
const {_id, tit, slug, awtis} = t
|
||||
const {id, tit, slug, awtis} = t
|
||||
const alias = awtis.map(a => a.alias).join('-')
|
||||
const slugUpdated = slugify(`${alias}-${tit}`, {lower: true, remove: /[*#+~.()'"!:@]/g})
|
||||
if (slug !== slugUpdated) {
|
||||
await strapi.query('teks').update(
|
||||
{_id},
|
||||
{id},
|
||||
{slug: slugUpdated}
|
||||
)
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
'use strict';
|
||||
|
||||
const jwennTeksEpiId = async teksId => {
|
||||
const teks = await strapi.query('teks').findOne({_id: teksId})
|
||||
const teks = await strapi.query('teks').findOne({id: teksId})
|
||||
return teks
|
||||
}
|
||||
|
||||
const jwennUserEpiId = async userId => {
|
||||
const user = await strapi.query('user', 'users-permissions').findOne({_id: userId})
|
||||
const user = await strapi.query('user', 'users-permissions').findOne({id: userId})
|
||||
return user
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ const TELEGRAM_API_TOKEN = process.env.TELEGRAM_API_TOKEN || null
|
||||
const MESSAGE_URL = `${TELEGRAM_API_URL}/bot${TELEGRAM_API_TOKEN}/sendMessage?chat_id=${TELEGRAM_CHAN_ID}&parse_mode=html`
|
||||
|
||||
const jwennAwtisEpiId = async data => {
|
||||
const awtis = await strapi.query('awtis').find({_id: data})
|
||||
const awtis = await strapi.query('awtis').find({id: data})
|
||||
return awtis.map(a => a.alias).join('-')
|
||||
}
|
||||
|
||||
@@ -59,8 +59,8 @@ module.exports = {
|
||||
data.slug = slugify(`${awtis}-${data.tit}`, {lower: true, remove: /[*#+~.()'"!:@]/g})
|
||||
}
|
||||
if (data.published_at != null) {
|
||||
const {_id} = params
|
||||
const previousData = await strapi.query('teks').findOne({_id})
|
||||
const {id} = params
|
||||
const previousData = await strapi.query('teks').findOne({id})
|
||||
|
||||
const previousPublishedAt = previousData.published_at
|
||||
const currentPublished_at = data.published_at
|
||||
|
||||
Reference in New Issue
Block a user