mirror of
https://github.com/MedzikUser/go-pingbot
synced 2024-08-04 09:52:33 +00:00
- license: changed from MIT to 0BSD - database: added retry to connect - api: modified status - config: moved to files env and no-env - other modified: nodemon.json, .gitignore
18 lines
298 B
Go
18 lines
298 B
Go
package database
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"go.mongodb.org/mongo-driver/mongo"
|
|
)
|
|
|
|
func Insert(url *URL) (*mongo.InsertOneResult, error) {
|
|
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
|
defer cancel()
|
|
|
|
result, err := Coll.InsertOne(ctx, url)
|
|
|
|
return result, err
|
|
}
|