mirror of https://github.com/MedzikUser/go-pingbot
fix(api): delete url from database
This commit is contained in:
parent
8d901b1160
commit
b8f70413cf
|
@ -2,8 +2,10 @@ package mongo
|
|||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
)
|
||||
|
||||
|
@ -11,9 +13,11 @@ func Delete(url string) (*mongo.DeleteResult, error) {
|
|||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
|
||||
result, err := Coll.DeleteOne(ctx, json{
|
||||
"url": url,
|
||||
})
|
||||
r, err := Coll.DeleteOne(ctx, bson.M{"_id": url})
|
||||
if err != nil {
|
||||
fmt.Print(err)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return result, err
|
||||
return r, err
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ func Delete(c *gin.Context) {
|
|||
if r.DeletedCount <= 0 {
|
||||
c.JSON(http.StatusNotFound, json{
|
||||
"success": false,
|
||||
"message": "Not found!",
|
||||
"message": "Not Found!",
|
||||
})
|
||||
|
||||
return
|
||||
|
|
Loading…
Reference in New Issue