probo/store/file/collection.go

28 lines
897 B
Go
Raw Normal View History

package file
import (
"git.andreafazzi.eu/andrea/probo/models"
2023-11-13 21:01:12 +01:00
"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]())
}
2023-11-20 14:14:09 +01:00
func NewDefaultCollectionFileStore() (*CollectionFileStore, error) {
return NewCollectionFileStore(
&FileStoreConfig[*models.Collection, *store.CollectionStore]{
2023-11-21 15:12:13 +01:00
FilePathConfig: FilePathConfig{GetDefaultCollectionsDir(), "collection", ".json"},
2023-11-20 14:14:09 +01:00
IndexDirFunc: DefaultIndexDirFunc[*models.Collection, *store.CollectionStore],
2023-11-21 18:24:10 +01:00
CreateEntityFunc: func() *models.Collection {
return &models.Collection{
Quizzes: make([]*models.Quiz, 0),
}
},
2023-11-20 14:14:09 +01:00
},
)
}