如果条件不起作用/不运行

时间:2016-10-18 06:06:22

标签: javascript mongodb mongojs

我正在尝试将mongodb对象ID与if条件匹配:

if (reply[i].data[j].ref == item._id) console.log('match!!!')

回复样本& item:

// REPLY
[{
   "_id":10,
    "data":  [
      {
        "_id":"57f485203858fe43b464ae52",
        "type":"product",
        "ref":"57f485473858fe43b464ae56",
        "name":"KARUNG",
        "direction":"in",
        "supplier":null,
        "information":"PENYESUAIAN JUMLAH",
        "qty":200,
        "manifest":null,
        "timestamp":"2016-10-05T04:44:16.354Z",
        "saldo":1200
      }
    ]
 }]

// ITEM
{
    "_id" : "57f485473858fe43b464ae56",
    "name" : "BERAS KC",
    "unit" : "SAK",
    "qty" : 213,
    "weight" : 10
}

我也尝试使用mongojs.ObjectId将它们转换为ObjectId,但它不起作用。

完整的代码段:http://pastebin.com/SYTLVWqT

0 个答案:

没有答案
相关问题