mirror of
https://github.com/MedzikUser/go-pingbot
synced 2024-08-14 23:57:07 +00:00
- database: added collection to var - website: changed gin.G to json type - api: status added cpu usage and move memory to stats - go: upgrade deps - update nodemon cfg and README
27 lines
405 B
Go
27 lines
405 B
Go
package database
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"go.mongodb.org/mongo-driver/bson"
|
|
)
|
|
|
|
func GetAll() ([]URL, error) {
|
|
var results []URL
|
|
|
|
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
|
defer cancel()
|
|
|
|
cursor, err := Coll.Find(ctx, bson.D{{}})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
err = cursor.All(ctx, &results)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return results, nil
|
|
}
|