using mgocrud interfaces instead of mgo

This commit is contained in:
2022-02-09 15:55:43 +01:00
parent 7b75e504ac
commit 119243297e
8 changed files with 22 additions and 27 deletions

View File

@@ -7,9 +7,8 @@ import (
"runtime/debug"
"gitbase.de/gopackage/mgocrud"
"gitbase.de/gopackage/mgocrud/v2"
"github.com/gin-gonic/gin"
mgo "gopkg.in/mgo.v2"
"gopkg.in/mgo.v2/bson"
)
@@ -42,7 +41,7 @@ func (api *API) collectionGetOneHandler(m mgocrud.ModelInterface) gin.HandlerFun
newM, err := getDocument(c, db, m, validSelect)
if err != nil {
status := 500
if err == mgo.ErrNotFound {
if err == mgocrud.ErrNotFound {
status = 404
}
c.JSON(status, errorObject(err))
@@ -265,7 +264,7 @@ func (api *API) collectionPutHandler(m mgocrud.ModelInterface) gin.HandlerFunc {
orgM, err := getDocument(c, db, m, nil)
if err != nil {
status := 500
if err == mgo.ErrNotFound {
if err == mgocrud.ErrNotFound {
status = 404
}
c.JSON(status, errorObject(err))
@@ -407,7 +406,7 @@ func (api *API) collectionDeleteHandler(m mgocrud.ModelInterface) gin.HandlerFun
orgM, err := getDocument(c, db, m, bson.M{"_id": 1})
if err != nil {
status := 500
if err == mgo.ErrNotFound {
if err == mgocrud.ErrNotFound {
status = 404
}
c.JSON(status, errorObject(err))