2024-12-18 19:39:57 +02:00
|
|
|
package repositories
|
|
|
|
|
|
|
|
import repositorymodels "github.com/pikami/cosmium/internal/repository_models"
|
|
|
|
|
|
|
|
type DataRepository struct {
|
2025-01-06 20:45:43 +02:00
|
|
|
storeState repositorymodels.State
|
2024-12-18 19:39:57 +02:00
|
|
|
|
|
|
|
initialDataFilePath string
|
|
|
|
persistDataFilePath string
|
|
|
|
}
|
|
|
|
|
|
|
|
type RepositoryOptions struct {
|
|
|
|
InitialDataFilePath string
|
|
|
|
PersistDataFilePath string
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewDataRepository(options RepositoryOptions) *DataRepository {
|
|
|
|
repository := &DataRepository{
|
|
|
|
storeState: repositorymodels.State{
|
2025-01-06 20:45:43 +02:00
|
|
|
Databases: make(map[string]repositorymodels.Database),
|
|
|
|
Collections: make(map[string]map[string]repositorymodels.Collection),
|
|
|
|
Documents: make(map[string]map[string]map[string]repositorymodels.Document),
|
|
|
|
Triggers: make(map[string]map[string]map[string]repositorymodels.Trigger),
|
|
|
|
StoredProcedures: make(map[string]map[string]map[string]repositorymodels.StoredProcedure),
|
|
|
|
UserDefinedFunctions: make(map[string]map[string]map[string]repositorymodels.UserDefinedFunction),
|
2024-12-18 19:39:57 +02:00
|
|
|
},
|
|
|
|
initialDataFilePath: options.InitialDataFilePath,
|
|
|
|
persistDataFilePath: options.PersistDataFilePath,
|
|
|
|
}
|
|
|
|
|
|
|
|
repository.InitializeRepository()
|
|
|
|
|
|
|
|
return repository
|
|
|
|
}
|