package sloppy

import (
	"sync"

	"github.com/fiskerinc/cloud-services/pkg/db"
	"github.com/fiskerinc/cloud-services/pkg/db/queries"
	"github.com/fiskerinc/cloud-services/pkg/logger"
)

var (
	carsDB     queries.CarsInterface
	carsDBOnce sync.Once
)

func GetCarsDB() queries.CarsInterface {
	carsDBOnce.Do(func() {
		if carsDB != nil {
			return
		}
		client := &db.DBClient{}
		logger.Debug().Msg("Init Cars instance")
		cars := &queries.Cars{}
		cars.SetClient(client)
		carsDB = cars
	})
	return carsDB
}
