27 lines
897 B
Go
27 lines
897 B
Go
package file
|
|
|
|
import (
|
|
"git.andreafazzi.eu/andrea/probo/models"
|
|
"git.andreafazzi.eu/andrea/probo/store"
|
|
)
|
|
|
|
type CollectionFileStore = FileStore[*models.Collection, *store.Store[*models.Collection]]
|
|
|
|
func NewCollectionFileStore(config *FileStoreConfig[*models.Collection, *store.CollectionStore]) (*CollectionFileStore, error) {
|
|
return NewFileStore[*models.Collection](config, store.NewStore[*models.Collection]())
|
|
}
|
|
|
|
func NewDefaultCollectionFileStore() (*CollectionFileStore, error) {
|
|
return NewCollectionFileStore(
|
|
&FileStoreConfig[*models.Collection, *store.CollectionStore]{
|
|
FilePathConfig: FilePathConfig{GetDefaultCollectionsDir(), "collection", ".json"},
|
|
IndexDirFunc: DefaultIndexDirFunc[*models.Collection, *store.CollectionStore],
|
|
CreateEntityFunc: func() *models.Collection {
|
|
return &models.Collection{
|
|
Quizzes: make([]*models.Quiz, 0),
|
|
}
|
|
},
|
|
},
|
|
)
|
|
|
|
}
|