我有一个文档,里面有子文档。此子文档具有id
字段。
我想进行查询以查找子文档id
等于数组
我做以下
Model.find({ product: { id: { $in: [arrayOfIdToFind] } } }).exec
但我收到错误
message: 'Cast to number failed for value "{ \'$in\': \n [ 6179,\n 5914,\n 6168,\n 5898,\n 6164,\n 9770,\n 5956,\n 6176,\n 9752,\n 10659,\n 18065,\n 18269,\n 18285,\n 9761,\n 9773,\n 9756,\n 14860,\n 18074,\n 18253,\n 18272,\n 18298,\n 14871,\n 14861,\n 18068,\n 18217,\n 18271 ] }" at path "id"',
name: 'CastError',
stringValue: '"{ \'$in\': \n [ 6179,\n 5914,\n 6168,\n 5898,\n 6164,\n 9770,\n 5956,\n 6176,\n 9752,\n 10659,\n 18065,\n 18269,\n 18285,\n 9761,\n 9773,\n 9756,\n 14860,\n 18074,\n 18253,\n 18272,\n 18298,\n 14871,\n 14861,\n 18068,\n 18217,\n 18271 ] }"',
kind: 'number',
value: { '$in': [Array] },
path: 'id',
reason: undefined },
如何解决?