小编PRE*_*DAV的帖子

在 Mongoose 中使用 AND 从两个 OR 查询中获取结果

我正在将两个 OR 查询与 mongoose 中的 AND 结合起来,但没有得到想要的结果

{
  _id :"23432ferf",
  "catId" : 21,
  "attributes": [
        {
          "_id": "571237bfc02aad440c216f67",
          "attributeValueM": "metal|Frame Material"
        },
        {
          "_id": "571237bfc02aad440c216f66",
          "attributeValueM": "green|color"
        }
  ]
},
{
   _id :"23432ferh",
  "catId" : 21,
  "attributes": [
        {
          "_id": "571237bfc02aad440c216f67",
          "attributeValueM": "metal|Frame Material"
        },
        {
          "_id": "571237bfc02aad440c216f66",
          "attributeValueM": "blue|color"
        }
  ]
}
Run Code Online (Sandbox Code Playgroud)

现在通过猫鼬查询是

var condition =  [
           { $or: [{ 'attributes.attributeValueM' : 'wood|Frame Material' }, { 'attributes.attributeValueM' : 'metal/Frame Material' }] },
           { $or: [{ 'attributes.attributeValueM' : 'blue|color' }, …
Run Code Online (Sandbox Code Playgroud)

mongoose mongodb node.js

3
推荐指数
1
解决办法
3075
查看次数

标签 统计

mongodb ×1

mongoose ×1

node.js ×1