mirror of
https://github.com/MedzikUser/go-pingbot
synced 2024-08-14 23:57:07 +00:00
26 lines
360 B
Go
26 lines
360 B
Go
package mongo
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
)
|
|
|
|
func GetAll() ([]URL, error) {
|
|
var results []URL
|
|
|
|
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
|
defer cancel()
|
|
|
|
cursor, err := Coll.Find(ctx, URL{})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
err = cursor.All(ctx, &results)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return results, nil
|
|
}
|