可选参数不适用于Sequelize Node.js

时间:2018-10-19 19:00:23

标签: node.js sequelize.js

URL的续集和参数出现问题。

我想要的是:

将URL中的参数传递给续集的controller,以便进行搜索。只是我通过了optional params,但是续集不接受它们并返回0

我的网址:

app.get('/api/updated2018/l1/:l1/:manager?/:city?/:country?/:squad?/:domain?/:subdomain?', wfmSkillsController.getUpdated2018L1);

我的续集:

getUpdated2018L1(req, res) {
  return WfmSkillTable
    .findAll({
      where: {
        l1_exec: req.params.l1,
        functional_manager: req.params.manager,
        city: req.params.city,
        country: req.params.country,
        squad_name: req.params.squad,
        domain_name: req.params.domain,
        subdomain_name: req.params.subdomain,
        update_in_2018: {
          [Op.notIn]: ["0"]
        },
        is_in_scope_employee_type: {
          [Op.notIn]: ["No"]
        },
        is_gdpr_country: {
          [Op.notIn]: ["Yes"]
        }
      }
    })
    .then(result => res.status(200).send({
      count: result.length
    }))
    .catch(error => res.status(400).send(error));
},

必要的唯一参数是l1,如果其他参数是empty,我想全部返回,但是如果我不输入某些参数,则它什么也不返回(0)。

我在邮递员中的API

  

http://localhost:8000/api/updated2018/l1/Blabla/%20/%20/%20/%20/%20/%20/

必要的唯一参数是Blabla,即l1

有人知道为什么吗?

0 个答案:

没有答案
相关问题