АП
https://t.me/nodejs_ru/585793 (второе предложение)
Но если что, я уловил, что именно ты называешь каноничным миддлварями (логгер, метрики). Видимо речь о том, что оставаясь в рамках каноничных миддлварей можем не считать их антипаттерном
Size: a a a
АП
V
V
OL
AV
export async function add(<SomeAttrs here>, tags, <SomeAttrs here>) {
try {
const myArticle = new Article({ <SomeAttrs here> });
await myArticle.save();
for (const tag of tags) {
await new Tags({ tag: tag['tag'] }).save();
}
const articleId = await knex.raw(`select nextval('article_id_seq')`);
tags.forEach(async (_tag) => {
const tagId = await knex.raw(`select nextval('article_tag_id_seq')`);
try {
await myArticle.related('tags').create({
articleId: Number(articleId.rows[0]['nextval']) - 1,
tagId: Number(tagId.rows[0]['nextval']) - 3
});
} catch (err) {
throw err;
}
});
return myArticle;
} catch (error) {
throw new BadRequestError(error.message);
}
}
WC
A
a
ДФ
PS
export async function add(<SomeAttrs here>, tags, <SomeAttrs here>) {
try {
const myArticle = new Article({ <SomeAttrs here> });
await myArticle.save();
for (const tag of tags) {
await new Tags({ tag: tag['tag'] }).save();
}
const articleId = await knex.raw(`select nextval('article_id_seq')`);
tags.forEach(async (_tag) => {
const tagId = await knex.raw(`select nextval('article_tag_id_seq')`);
try {
await myArticle.related('tags').create({
articleId: Number(articleId.rows[0]['nextval']) - 1,
tagId: Number(tagId.rows[0]['nextval']) - 3
});
} catch (err) {
throw err;
}
});
return myArticle;
} catch (error) {
throw new BadRequestError(error.message);
}
}
T
A
SK
T
T
T
T