go-pingbot/database/insert.go
Medzik f1921ff8b1 v1.3.0
- 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
2021-07-24 09:50:17 +00:00

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
}