let allSkills = await strapi.entityService.findMany(‘api::skill.skill’, { filters: {…
- User
let allSkills = await strapi.entityService.findMany(‘api::skill.skill’, { filters: { $not: { is_blokced: 1, }, }, }); 多个过滤条件。 const card_class = ctx.request.query.card_class; const health = ctx.request.query.health; const attack = ctx.request.query.attack; const cost = ctx.request.query.cost; 这几个参数 同时相同 的过滤条件应该怎么写
- Assistant
可以使用
$and运算符将多个相同的过滤条件组合起来。下面是一个示例:const allSkills = await strapi.entityService.findMany('api::skill.skill', { filters: { $and: [ { card_class: card_class }, { health: health }, { attack: attack }, { cost: cost }, ], $not: { is_blocked: 1, }, }, });在上述示例中,通过使用
$and运算符将card_class、health、attack和cost参数的相同过滤条件组合在一起,并且添加了排除is_blocked: 1的条件。请注意,这里使用了正确的属性名称,并且使用了下划线_代替了is_blokced。最后,可以使用上述代码来过滤具有相同条件的记录。
- User
重新回答下
- Assistant
如果要同时将多个参数作为相同过滤条件进行查询,可以使用逻辑运算符
$and将它们组合在一起。以下是一个示例:const card_class = ctx.request.query.card_class; const health = ctx.request.query.health; const attack = ctx.request.query.attack; const cost = ctx.request.query.cost; const allSkills = await strapi.entityService.findMany('api::skill.skill', { filters: { $and: [ { card_class: card_class }, { health: health }, { attack: attack }, { cost: cost } ], is_blocked: { $ne: 1 } } });在上面的示例中,使用逻辑运算符
$and将参数card_class、health、attack和cost的过滤条件组合在一起,同时使用$ne运算符将is_blocked的值排除为 1。请注意,以上代码假设参数已经正确传递,并且通过检查参数的有效性和存在性来避免潜在的错误。
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.