fix article populate
This commit is contained in:
@@ -56,9 +56,15 @@ export class ArticleController extends Controller {
|
|||||||
});
|
});
|
||||||
|
|
||||||
for (const [index, tagId] of body.tag_ids.entries()) {
|
for (const [index, tagId] of body.tag_ids.entries()) {
|
||||||
const tag = await orm.em.findOne(Tag, {
|
const tag = await orm.em.findOne(
|
||||||
id: tagId,
|
Tag,
|
||||||
});
|
{
|
||||||
|
id: tagId,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
populate: ["*"],
|
||||||
|
},
|
||||||
|
);
|
||||||
if (!tag) {
|
if (!tag) {
|
||||||
return res.status(404).json({
|
return res.status(404).json({
|
||||||
data: null,
|
data: null,
|
||||||
@@ -101,6 +107,7 @@ export class ArticleController extends Controller {
|
|||||||
limit: query.per_page,
|
limit: query.per_page,
|
||||||
offset: (query.page - 1) * query.per_page,
|
offset: (query.page - 1) * query.per_page,
|
||||||
orderBy: { createdAt: "DESC" },
|
orderBy: { createdAt: "DESC" },
|
||||||
|
populate: ["*"],
|
||||||
});
|
});
|
||||||
|
|
||||||
return res.status(200).json({
|
return res.status(200).json({
|
||||||
@@ -122,7 +129,13 @@ export class ArticleController extends Controller {
|
|||||||
}
|
}
|
||||||
const params = parseParamsResult.data;
|
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) {
|
if (!article) {
|
||||||
return res.status(404).json({
|
return res.status(404).json({
|
||||||
data: null,
|
data: null,
|
||||||
@@ -159,7 +172,13 @@ export class ArticleController extends Controller {
|
|||||||
}
|
}
|
||||||
const body = parseBodyResult.data;
|
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) {
|
if (!article) {
|
||||||
return res.status(404).json({
|
return res.status(404).json({
|
||||||
data: null,
|
data: null,
|
||||||
|
|||||||
Reference in New Issue
Block a user