fix article populate

This commit is contained in:
ItsMalma
2025-12-12 12:33:17 +07:00
parent 1a4ee566ac
commit 9ac6e9e3fd

View File

@@ -56,9 +56,15 @@ export class ArticleController extends Controller {
});
for (const [index, tagId] of body.tag_ids.entries()) {
const tag = await orm.em.findOne(Tag, {
id: tagId,
});
const tag = await orm.em.findOne(
Tag,
{
id: tagId,
},
{
populate: ["*"],
},
);
if (!tag) {
return res.status(404).json({
data: null,
@@ -101,6 +107,7 @@ export class ArticleController extends Controller {
limit: query.per_page,
offset: (query.page - 1) * query.per_page,
orderBy: { createdAt: "DESC" },
populate: ["*"],
});
return res.status(200).json({
@@ -122,7 +129,13 @@ export class ArticleController extends Controller {
}
const params = parseParamsResult.data;
const article = await orm.em.findOne(Article, { slug: params.slug });
const article = await orm.em.findOne(
Article,
{ slug: params.slug },
{
populate: ["*"],
},
);
if (!article) {
return res.status(404).json({
data: null,
@@ -159,7 +172,13 @@ export class ArticleController extends Controller {
}
const body = parseBodyResult.data;
const article = await orm.em.findOne(Article, { slug: params.slug });
const article = await orm.em.findOne(
Article,
{ slug: params.slug },
{
populate: ["*"],
},
);
if (!article) {
return res.status(404).json({
data: null,