我如何查询MongoDB?

时间:2017-04-18 06:24:11

标签: mongodb

我刚刚创建了一个集合,并且我正在尝试查询文档中的某些对象,但我似乎没有得到任何结果。顺便说一下,我使用Robomongo作为mongoDB的GUI。这些是我的文件。

/* 1 */
{
"_id" : ObjectId("58f58ba6739e558ced008df1"),
"Inventory for NTA SAM Cards" : "Item no.",
"Item Description" : "",
"Opening QTY" : "",
"Issued QTY" : "",
"Corrupted QTY" : "",
"Closing QTY" : ""
}

/* 2 */
{
"_id" : ObjectId("58f58f23739e558ced008e3d"),
"Inventory for NTA SAM Cards" : "01",
"Item Description" : "EZ-Link SAM (Blank)",
"Opening QTY" : "165",
"Issued QTY" : "65",
"Corrupted QTY" : "0",
"Closing QTY" : "100",
"Remarks" : "Received 100 blank SAMS from Geraldine on 4/1/15"
 }

/* 3 */
{
"_id" : ObjectId("58f58f9c739e558ced008e47"),
"Inventory for NTA SAM Cards" : "02",
"Item Description" : "EZ-Link SAM (Test)",
"Opening QTY" : "220",
"Issued QTY" : "184",
"Corrupted QTY" : "0",
"Closing QTY" : "36",
"Remarks" : "updated 7/11/16"
 }

 /* 4 */
 {
"_id" : ObjectId("58f58fcd739e558ced008e4d"),
"Inventory for NTA SAM Cards" : "03",
"Item Description" : "EZL Production SAM",
"Opening QTY" : "998",
"Issued QTY" : "996",
"Corrupted QTY" : "0",
"Closing QTY" : "2",
"Remarks" : "updated 11/11/2016 150 moved to 18.Auresys Prod"
 }

 /* 5 */
 {
"_id" : ObjectId("58f59034739e558ced008e57"),
"Inventory for NTA SAM Cards" : "04",
"Item Description" : "Payment Link SAM",
"Opening QTY" : "500",
"Issued QTY" : "500",
"Corrupted QTY" : "0",
"Closing QTY" : "0",
"Remarks" : ""
 }

 /* 6 */
{
"_id" : ObjectId("58f5a1b2739e558ced008f2e"),
"Inventory for NTA SAM Cards" : "05",
"Item Description" : "MEA Production SAM",
"Opening QTY" : "434",
"Issued QTY" : "393",
"Corrupted QTY" : "0",
"Closing QTY" : "41",
"Remarks" : ""
}

有谁知道这个问题是什么?我的问题是

 db.documents.find({"Inventory for NTA SAM Cards":"01"})

我一直得到这个

Fetched 0 record(s) in 2ms

我的收藏称为文件。

1 个答案:

答案 0 :(得分:0)

尝试此查询

db.documents.find( { Inventory for NTA SAM Cards: { $eq: "01" } } )

供参考,请暂停此链接

db.collection.find

相关问题