2013-12-19 115 views
0

我試圖檢索使用這個從MongoDB中記錄:紅寶石蒙戈DB找到方法

client = MongoClient.new("something.com",27017).db("big_data_api_development") 
coll = client.collection("dni_logs") 
dni = coll.find({"data" => {"session_id" => "aaa"}}).to_a 

這是創紀錄的樣子:

{ 
"_id" : ObjectId("5272198be77989f5be019323"), 
"data" : { 
    "dni_id" : "102329", 
    "phone_number_id" : "10403", 
    "phone_number_pool_id" : null, 
    "master_node_id" : "686", 
    "organizational_unit_id" : "896", 
    "phone_number" : "888888888", 
    "session_id" : "aaa", 
    "ip_host" : "10.204.201.245", 
    "browser" : "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:19.0) Gecko/20100101 Firefox/19.0 AlexaToolbar/alxf-2.17", 
    "log_date" : "2013-04-08 19:02:03", 
    "referring" : "google", 
    "referring_type" : "Organic", 
    "search_words" : "Not Available", 
    "ref_params" : null, 
    "custome_params" : null 
}, 
"created_at" : ISODate("2013-04-09T00:02:03.000Z"), 
"_keywords" : [ 
    "02", 
    "03", 
    "04", 
], 
"updated_at" : ISODate("2013-10-31T08:49:15.227Z") 
} 

我回回來是一個空數組。這是檢索記錄的正確方法嗎? 感謝

回答

0

試試這個

dni = coll.find({data: {session_id: "aaa"}}).to_a 
+0

我已經試過了,並得到一個空數組。 – rstewart8