pembaruhan baru
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
package mongo
|
||||
|
||||
import (
|
||||
"api-poliklinik/pkg/models/mongo/appointment"
|
||||
"context"
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"log"
|
||||
"time"
|
||||
)
|
||||
|
||||
func (s *DatabaseService) Getappointment() ([]*appointment.Appointment, error) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
dataappointment, err := s.DBMongo.Collection("location").Find(ctx, bson.D{})
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
var appointment []*appointment.Appointment
|
||||
err = dataappointment.All(ctx, &appointment)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
return nil, err
|
||||
}
|
||||
return appointment, nil
|
||||
}
|
||||
@@ -0,0 +1,198 @@
|
||||
package mongo
|
||||
|
||||
import (
|
||||
Mongomaster "api-poliklinik/pkg/models/mongo/master/masteraddress"
|
||||
"context"
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"log"
|
||||
"time"
|
||||
)
|
||||
|
||||
func (s *DatabaseService) Insertcommunication(req Mongomaster.Communication) error {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
_, err := s.DBMongo.Collection("communication").InsertOne(ctx, req)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *DatabaseService) Insertdisability(req Mongomaster.Disability) error {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
_, err := s.DBMongo.Collection("disability").InsertOne(ctx, req)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *DatabaseService) Inserteducation(req Mongomaster.Education) error {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
_, err := s.DBMongo.Collection("education").InsertOne(ctx, req)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *DatabaseService) Insertjob(req Mongomaster.Job) error {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
_, err := s.DBMongo.Collection("job").InsertOne(ctx, req)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *DatabaseService) Insertmartial(req Mongomaster.MartialStatus) error {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
_, err := s.DBMongo.Collection("martialstatus").InsertOne(ctx, req)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *DatabaseService) Insertreligion(req Mongomaster.Religion) error {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
_, err := s.DBMongo.Collection("religion").InsertOne(ctx, req)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *DatabaseService) Inserttribe(req Mongomaster.Tribe) error {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
_, err := s.DBMongo.Collection("tribe").InsertOne(ctx, req)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *DatabaseService) Getcommunication() ([]*Mongomaster.Communication, error) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
datacommunication, err := s.DBMongo.Collection("communication").Find(ctx, bson.D{})
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
var komunikasi []*Mongomaster.Communication
|
||||
err = datacommunication.All(ctx, &komunikasi)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
return nil, err
|
||||
}
|
||||
return komunikasi, nil
|
||||
}
|
||||
|
||||
func (s *DatabaseService) Getdisability() ([]*Mongomaster.Disability, error) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
datadisabilitas, err := s.DBMongo.Collection("disability").Find(ctx, bson.D{})
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
var disabilitas []*Mongomaster.Disability
|
||||
err = datadisabilitas.All(ctx, &disabilitas)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
return nil, err
|
||||
}
|
||||
return disabilitas, nil
|
||||
}
|
||||
|
||||
func (s *DatabaseService) Geteducation() ([]*Mongomaster.Education, error) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
datapendidikan, err := s.DBMongo.Collection("education").Find(ctx, bson.D{})
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
var pendidikan []*Mongomaster.Education
|
||||
err = datapendidikan.All(ctx, &pendidikan)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
return nil, err
|
||||
}
|
||||
return pendidikan, nil
|
||||
}
|
||||
|
||||
func (s *DatabaseService) Getjob() ([]*Mongomaster.Job, error) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
datapekerjaan, err := s.DBMongo.Collection("job").Find(ctx, bson.D{})
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
var pekerjaan []*Mongomaster.Job
|
||||
err = datapekerjaan.All(ctx, &pekerjaan)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
return nil, err
|
||||
}
|
||||
return pekerjaan, nil
|
||||
}
|
||||
|
||||
func (s *DatabaseService) Getmartial() ([]*Mongomaster.MartialStatus, error) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
datapernikahan, err := s.DBMongo.Collection("martialstatus").Find(ctx, bson.D{})
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
var pernikahan []*Mongomaster.MartialStatus
|
||||
err = datapernikahan.All(ctx, &pernikahan)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
return nil, err
|
||||
}
|
||||
return pernikahan, nil
|
||||
}
|
||||
|
||||
func (s *DatabaseService) Getreligion() ([]*Mongomaster.Religion, error) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
dataagama, err := s.DBMongo.Collection("religion").Find(ctx, bson.D{})
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
var agama []*Mongomaster.Religion
|
||||
err = dataagama.All(ctx, &agama)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
return nil, err
|
||||
}
|
||||
return agama, nil
|
||||
}
|
||||
|
||||
func (s *DatabaseService) Getsuku() ([]*Mongomaster.Tribe, error) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
datasuku, err := s.DBMongo.Collection("tribe").Find(ctx, bson.D{})
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
var suku []*Mongomaster.Tribe
|
||||
err = datasuku.All(ctx, &suku)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
return nil, err
|
||||
}
|
||||
return suku, nil
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package mongo
|
||||
|
||||
import (
|
||||
"api-poliklinik/pkg/models/mongo/location"
|
||||
"context"
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"log"
|
||||
"time"
|
||||
)
|
||||
|
||||
func (s *DatabaseService) Insertlokasi(req location.Location) error {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
_, err := s.DBMongo.Collection("location").InsertOne(ctx, req)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *DatabaseService) Getlocation() ([]*location.Location, error) {
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
datalocation, err := s.DBMongo.Collection("location").Find(ctx, bson.D{})
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
var location []*location.Location
|
||||
err = datalocation.All(ctx, &location)
|
||||
if err != nil {
|
||||
log.Println(err)
|
||||
return nil, err
|
||||
}
|
||||
return location, nil
|
||||
}
|
||||
Reference in New Issue
Block a user