0
從MongoDB的一個數據是無法檢索值
{
"_id" : ObjectId("5536def4e4b0644323e219a8"),
"title" : "The Title",
"description" : "The Description",
"timeStamp" : "21/04/2015",
"category" : "news",
"url" : "http://www.example.com",
"source" : "Evening Times",
"mainStory" : "This is the main story."
}
在我的代碼,結構
type NewsData struct {
Title string `bson: "title" json: "title"`
TimeStamp string `bson: "timeStamp" json: "timeStamp"`
Description string `bson: "description" json: "description"`
MainStory string `bson: "mainStory" json:"mainStory"`
}
然後我用下面的代碼中提取信息
err = conn.Find(nil).Select(bson.M{"title": 1, "timeStamp": 1, "description": 1, "mainStory": 1}).All(&result)
但是,當我打印result
輸出時,值爲timeStamp
和mainStory
爲空。我檢查了這些文件,它說mgo把鑰匙當作小寫字母,所以當mongoDB中的鑰匙包含大寫字母時,這將是一個問題。
我該如何解決這個問題?