简体   繁体   English

[ERR_INVALID_ARG_TYPE]:“id”参数必须是字符串类型。 接收类型对象

[英][ERR_INVALID_ARG_TYPE]: The "id" argument must be of type string. Received type object

By this method, I got an error:通过这种方法,我得到了一个错误:

The "id" argument must be of type string. “id”参数必须是字符串类型。 Received type object接收类型对象

I don't understand what is wrong here.我不明白这里有什么问题。

const customers = await Customer.findAll({
  where: { id: _.map(users, 'customerId') }
});

if (customers) {
  const status = req.query.activation
    ? await Customer.findAll({ where: { activation: req.query.activation } })
    : customers;
  const search = req.query.search
    ? await Customer.findAll({
        name: { where: { [Op.like]: '%' + req.query.search + '%' } }
      })
    : status;

  return res.json({ search });
}
return response.sendBadRequest(res, 'customers empty!');

Your id is string, i think for that we don't need to see your model你的 id 是字符串,我认为我们不需要看到你的模型

but _.map produces an array not a string但 _.map 产生一个数组而不是一个字符串

 map_.map(list, iteratee, [context]) Alias: collect
Produces a new array of values by mapping each value in list through a transformation function (iteratee). The iteratee is passed three arguments: the value, then the index (or key) of the iteration, and finally a reference to the entire list.

_.map([1, 2, 3], function(num){ return num * 3; });
=> [3, 6, 9]

Undeerscorejs Homepage Undeerscorejs 主页

So what you can do is using join to get your string所以你可以做的是使用 join 来获取你的字符串

const customers = await Customer.findAll({ where: {id: _.map(users, 'customerId' ).join('') }})

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 类型错误 [ERR_INVALID_ARG_TYPE]:“文件”参数必须是字符串类型。 接收类型对象 - TypeError [ERR_INVALID_ARG_TYPE]: The "file" argument must be of type string. Received type object 等待 dTypeError [ERR_INVALID_ARG_TYPE]:“id”参数必须是字符串类型。 收到未定义 - Waiting for the dTypeError [ERR_INVALID_ARG_TYPE]: The “id” argument must be of type string. Received undefined TypeError [ERR_INVALID_ARG_TYPE]:“路径”参数必须是字符串类型。 收到 Object 的实例 - TypeError [ERR_INVALID_ARG_TYPE]: The “path” argument must be of type string. Received an instance of Object TypeError [ERR_INVALID_ARG_TYPE]:“路径”参数必须是字符串类型。 收到未定义和代码:'ERR_INVALID_ARG_TYPE' - TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined and code: 'ERR_INVALID_ARG_TYPE' Node.js 应用程序类型错误 [ERR_INVALID_ARG_TYPE]:“路径”参数必须是字符串类型。 接收类型对象 - Node.js app TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type object ERR_INVALID_ARG_TYPE - “from” 参数必须是字符串类型。 接收到一个 Array 实例 - ERR_INVALID_ARG_TYPE - The “from” argument must be of type string. Received an instance of Array Webpack 类型错误'TypeError [ERR_INVALID_ARG_TYPE]:“路径”参数必须是字符串类型。 接收类型布尔值(真)' - Webpack type error 'TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type boolean (true)' 图片上传错误:TypeError [ERR_INVALID_ARG_TYPE]:“路径”参数必须是字符串类型。 接收类型未定义 - Image Upload Error: TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined 错误:TypeError [ERR_INVALID_ARG_TYPE]:“路径”参数必须是字符串类型。 尝试 node utils/nftport/uploadFiles.js 时收到 undefined - error:TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined when trying node utils/nftport/uploadFiles.js TypeError [ERR_INVALID_ARG_TYPE]:“id”参数必须是字符串类型 - TypeError [ERR_INVALID_ARG_TYPE]: The "id" argument must be of type string
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM