我正在尝试使用slug获取单个类别
http://localhost:1337/api/categories/{slug}
在我的控制器中:
async findOne(ctx) {
const {id : slug} = ctx.params
const response = await strapi.db
.query("api::category.category")
.findOne({
where: { slug: slug },
populate: {
blogs: {
select: ["id", "title"],
orderBy: ["id"],
},
},
});
这工作正常...但是当添加另一个字段时
select: ["id", "title", "image"],
我得到了错误
错误:选择不同的t1
、blog_order
、t0
、id
、t0
、id
、t0
、title
、t0
、image
,t1
。category_id
从blogs
作为t0
向左加入categories_blogs_links
作为t0
上的t1
。id
= t1
。blog_id
其中((2)中的t1
. category_id
)按t0
. id
升序、t1
. blog_order
升序排序-无此列:t0.图像方型错误:选择不同的t1
、blog_order
、t0
、id
、t0
、id
、t0
、title
、t0
、image
,t1
。category_id
从blogs
作为t0
向左加入categories_blogs_links
作为t1
到t0
。id
= t1
。blog_id
其中((2)中的t1
. category_id
)按t0
. id
升序、t1
. blog_order
升序排序-无此类列:t0.image
但是有一个字段叫做"图像"
2条答案
按热度按时间bweufnob1#
很有趣的填充用法,其实没想到你可以在填充里面排序和选择。
你遇到的问题很可能是因为你必须显式地填充内部的关系。
egdjgwm82#
我得到这个错误的原因是因为媒体字段没有存储在数据库中,所以sqlite正在寻找一个不存在的列。所以我们可能必须单独填充它。