using mgocrud interfaces instead of mgo
This commit is contained in:
11
register.go
11
register.go
@@ -1,14 +1,13 @@
|
||||
package mgoapi
|
||||
|
||||
import (
|
||||
"gitbase.de/gopackage/mgocrud"
|
||||
"gitbase.de/gopackage/mgocrud/v2"
|
||||
"github.com/gin-gonic/gin"
|
||||
mgo "gopkg.in/mgo.v2"
|
||||
)
|
||||
|
||||
// API is wrapper for one RouterGroup and mgo DB
|
||||
type API struct {
|
||||
DBSession *mgo.Session
|
||||
DBSession *mgocrud.Session
|
||||
DBName string
|
||||
routerGroup *gin.RouterGroup
|
||||
jwtSecret []byte
|
||||
@@ -19,11 +18,11 @@ type API struct {
|
||||
type Context struct {
|
||||
*gin.Context
|
||||
API *API
|
||||
DB *mgo.Database
|
||||
DB *mgocrud.Database
|
||||
}
|
||||
|
||||
// New returns new instance of the API
|
||||
func New(session *mgo.Session, dbname string, routerGroup *gin.RouterGroup) *API {
|
||||
func New(session *mgocrud.Session, dbname string, routerGroup *gin.RouterGroup) *API {
|
||||
return &API{
|
||||
DBSession: session,
|
||||
DBName: dbname,
|
||||
@@ -31,7 +30,7 @@ func New(session *mgo.Session, dbname string, routerGroup *gin.RouterGroup) *API
|
||||
}
|
||||
}
|
||||
|
||||
var modelRegistry = make([]mgocrud.ModelInterface, 0, 0)
|
||||
var modelRegistry = make([]mgocrud.ModelInterface, 0)
|
||||
|
||||
// RegisterModel setups gin routes for model GET, POST, PUT and DELETE
|
||||
func (api *API) RegisterModel(m mgocrud.ModelInterface) {
|
||||
|
||||
Reference in New Issue
Block a user