package mongo

import (
	"context"
	"log"
	"template_blueprint/pkg/models/master_data"
	"time"
)

func (s *DatabaseService) InsertDataMaster(req master_data.ReqInsertData) error {
	ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
	defer cancel()
	_, err := s.DB.Collection(req.Table).InsertOne(ctx, master_data.ReqInsertDataMaster{
		ID:      req.ID,
		System:  req.System,
		Code:    req.Code,
		Display: req.Display,
	})
	if err != nil {
		log.Println(err)
		return err
	}
	return nil
}
