27 lines
578 B
Go
27 lines
578 B
Go
package mongo
|
|
|
|
import (
|
|
"api-poliklinik/pkg/models/mongo/condition"
|
|
"context"
|
|
"go.mongodb.org/mongo-driver/bson"
|
|
"log"
|
|
"time"
|
|
)
|
|
|
|
func (s *DatabaseService) Getcondition() ([]*condition.Condition, error) {
|
|
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
|
defer cancel()
|
|
|
|
datacondition, err := s.DBMongo.Collection("condition").Find(ctx, bson.D{})
|
|
if err != nil {
|
|
log.Println(err)
|
|
}
|
|
var Condition []*condition.Condition
|
|
err = datacondition.All(ctx, &Condition)
|
|
if err != nil {
|
|
log.Println(err)
|
|
return nil, err
|
|
}
|
|
return Condition, nil
|
|
}
|