go-pingbot/database/getAll.go
Medzik 13771d1394 v1.2.0
- 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
2021-07-22 08:23:49 +00:00

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
}