go-pingbot/database/mongo/delete.go

24 lines
397 B
Go
Raw Normal View History

2021-07-29 18:51:15 +00:00
package mongo
2021-07-11 21:19:37 +00:00
import (
"context"
2021-08-01 18:26:48 +00:00
"fmt"
2021-07-11 21:19:37 +00:00
"time"
2021-08-01 18:26:48 +00:00
"go.mongodb.org/mongo-driver/bson"
2021-07-11 21:19:37 +00:00
"go.mongodb.org/mongo-driver/mongo"
)
2021-08-01 17:43:59 +00:00
func Delete(url string) (*mongo.DeleteResult, error) {
2021-07-11 21:19:37 +00:00
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
r, err := Coll.DeleteOne(ctx, bson.M{"_id": url})
2021-08-01 18:26:48 +00:00
if err != nil {
fmt.Print(err)
return nil, err
}
2021-07-11 21:19:37 +00:00
2021-08-01 18:26:48 +00:00
return r, err
2021-07-11 21:19:37 +00:00
}