如何通过mgo获取未知的mongo文档
Here is the piece of code that is trying to fetch all the docs from the mongodb.
func fetchAll(db *mgo.Database) map[string]interface {
var msg map[string]interface{}
err := db.C("msg").Find(nil).All(&msg)
if err != nil {
panic(err)
}
return msg
}
I got the error: syntax error: unexpected var
What is wrong here? And is there a better way to fetch the arbitrary mongo docs via mgo?
thanks
dpf25323
2014/09/18 20:38- mongodb
- 点赞
- 收藏
- 回答
满意答案
1个回复
