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中的钥匙包含大写字母时,这将是一个问题。
我该如何解决这个问题?