// Code generated by candi v1.3.1.

package repository

import (
	aclrepo "monorepo/services/master-service/internal/modules/acl/repository"
	appsrepo "monorepo/services/master-service/internal/modules/apps/repository"

	"go.mongodb.org/mongo-driver/mongo"
)

// RepoMongo uow
type RepoMongo struct {
	readDB, writeDB *mongo.Database

	// register all repository from modules
	ACLRepo        aclrepo.ACLRepository
	RoleRepo       aclrepo.RoleRepository
	AppsRepo       appsrepo.AppsRepository
	PermissionRepo appsrepo.PermissionRepository
}

var globalRepoMongo = new(RepoMongo)

// setSharedRepoMongo set the global singleton "RepoMongo" implementation
func setSharedRepoMongo(readDB, writeDB *mongo.Database) {
	globalRepoMongo = &RepoMongo{
		readDB: readDB, writeDB: writeDB,
		ACLRepo:        aclrepo.NewACLRepoMongo(readDB, writeDB),
		RoleRepo:       aclrepo.NewRoleRepoMongo(readDB, writeDB),
		AppsRepo:       appsrepo.NewAppsRepoMongo(readDB, writeDB),
		PermissionRepo: appsrepo.NewPermissionRepoMongo(readDB, writeDB),
	}
}

// GetSharedRepoMongo returns the global singleton "RepoMongo" implementation
func GetSharedRepoMongo() *RepoMongo {
	return globalRepoMongo
}
