mirror of
https://github.com/pikami/cosmium.git
synced 2025-02-02 22:18:38 +00:00
38 lines
1.2 KiB
Go
38 lines
1.2 KiB
Go
|
package repositories
|
||
|
|
||
|
import repositorymodels "github.com/pikami/cosmium/internal/repository_models"
|
||
|
|
||
|
type DataRepository struct {
|
||
|
storedProcedures []repositorymodels.StoredProcedure
|
||
|
triggers []repositorymodels.Trigger
|
||
|
userDefinedFunctions []repositorymodels.UserDefinedFunction
|
||
|
storeState repositorymodels.State
|
||
|
|
||
|
initialDataFilePath string
|
||
|
persistDataFilePath string
|
||
|
}
|
||
|
|
||
|
type RepositoryOptions struct {
|
||
|
InitialDataFilePath string
|
||
|
PersistDataFilePath string
|
||
|
}
|
||
|
|
||
|
func NewDataRepository(options RepositoryOptions) *DataRepository {
|
||
|
repository := &DataRepository{
|
||
|
storedProcedures: []repositorymodels.StoredProcedure{},
|
||
|
triggers: []repositorymodels.Trigger{},
|
||
|
userDefinedFunctions: []repositorymodels.UserDefinedFunction{},
|
||
|
storeState: repositorymodels.State{
|
||
|
Databases: make(map[string]repositorymodels.Database),
|
||
|
Collections: make(map[string]map[string]repositorymodels.Collection),
|
||
|
Documents: make(map[string]map[string]map[string]repositorymodels.Document),
|
||
|
},
|
||
|
initialDataFilePath: options.InitialDataFilePath,
|
||
|
persistDataFilePath: options.PersistDataFilePath,
|
||
|
}
|
||
|
|
||
|
repository.InitializeRepository()
|
||
|
|
||
|
return repository
|
||
|
}
|