我应该如何通过$和运营商在strapi中过滤数据
我想通过createat
,status_invitor
和status_invited
过滤我的表数据。我写这样的查询
const query = qs.stringify({
filters: {
$and: {
createdAt: { $gte: firstDayOfTheMonth },
createdAt: { $lt: lastDayOfTheMonth },
},
$and: {
status_invitor: statusFilter
},
status_invited: statusFilter,
},
});
,但无法正常工作
I want to filter my table data by createdAt
,status_invitor
and status_invited
. I write query Like this
const query = qs.stringify({
filters: {
$and: {
createdAt: { $gte: firstDayOfTheMonth },
createdAt: { $lt: lastDayOfTheMonth },
},
$and: {
status_invitor: statusFilter
},
status_invited: statusFilter,
},
});
but is not working correctly
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
默认情况下将过滤器组合在一起,因此除非我误解了您要实现的目标,否则您无需使用
$和
操作员。如果您确实想混合
和
和或过滤器,则需要指定一个数组。您可以在此处看到其中的示例: https://docs.strapi.io/developer-docs/latest/developer-resources/database-pabase-pabase-epis-reference/rest/filtering/filtering/filtering-localeing-locale--locale-publication一下/a>The filters are combined by default so unless I have misunderstood what you are trying to achieve, you don't need to use the
$and
operator.If you do want to mix
AND
andOR
filters then you need to specify an array. You can see examples of that here: https://docs.strapi.io/developer-docs/latest/developer-resources/database-apis-reference/rest/filtering-locale-publication.html#complex-filtering我正在从事一个项目,我想用一个以上的搜索字段查询一个以上的字段。这是我用来使其工作的代码。我认为您需要做的就是更改$或为$,并且应该可以使用。
I'm working on a project where I wanted to query more than one field with a search term. This is the code I used to get it working. I think all you need to do is change the $or for the $and and it should work.