如何将多个值传递给一个参数 [英] How to pass multiple values to one parameter

查看:86
本文介绍了如何将多个值传递给一个参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当前,我已完成代码以在参数中接受一个category_id并基于category_id返回输出.

Currently i have done code to accept one category_id in the param and return output base on category_id.

if ('category' in params) {
        assert.number(params.category, 'params.category')

        const { category: category_id } = params
        query = query.where('category.id', category_id)
      }

现在,我想将多个值传递给category_id并返回所有category_id的结果.

Now i want to pass multiple values to category_id and return result for all category_id's.

我会这样通过, category_id = 1,2,3

有人可以帮我解决这个问题吗?

Can someone helps me to fix this?

推荐答案

http://knexjs.org/#Builder-whereIn

query.whereIn('category.id', [1, 2, 3]);

这篇关于如何将多个值传递给一个参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆