如何通过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
dpf25323
2014/09/18 20:38
  • mongodb
  • 点赞
  • 收藏
  • 回答
    私信
满意答案
查看全部

1个回复