示例#1
0
文件: orm.go 项目: lnx1337/mongorm
func NewOrmWithContext(ctx context.Context, model interface{}) Orm {
	self := Orm{Model: model}
	val := reflect.ValueOf(model)

	d := self.GetModel("DbName", val)
	c := self.GetModel("CollectionName", val)

	Sess = db.MongoDB(ctx, "main")
	Collection = Sess.DB(d).C(c)

	return self
}
示例#2
0
func userStorage(ctx context.Context) *mgo.Collection {
	session := db.MongoDB(ctx, "main")
	return session.DB("petrucho").C("users")
}