38 lines
		
	
	
	
		
			631 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			38 lines
		
	
	
	
		
			631 B
		
	
	
	
		
			Go
		
	
	
	
	
	
| package sqlite
 | |
| 
 | |
| import (
 | |
| 	"codeberg.org/danjones000/combluotion/config"
 | |
| 	"codeberg.org/danjones000/combluotion/store"
 | |
| 	"github.com/go-ap/storage-sqlite"
 | |
| )
 | |
| 
 | |
| func init() {
 | |
| 	store.AddFactory("sqlite", MakeStore)
 | |
| }
 | |
| 
 | |
| type settings struct {
 | |
| 	Path string
 | |
| }
 | |
| 
 | |
| func MakeStore(conf config.Store) (store.Store, error) {
 | |
| 	var s settings
 | |
| 	err := conf.Decode(&s)
 | |
| 	if err != nil {
 | |
| 		return nil, err
 | |
| 	}
 | |
| 	sqlConf := sqlite.Config{Path: s.Path}
 | |
| 	db, err := sqlite.New(sqlConf)
 | |
| 	if err != nil {
 | |
| 		return nil, err
 | |
| 	}
 | |
| 	return Repo{db}, nil
 | |
| }
 | |
| 
 | |
| type Repo struct {
 | |
| 	store.PartStore
 | |
| }
 | |
| 
 | |
| func (r Repo) Bootstrap(config.Config) error {
 | |
| 	// @todo
 | |
| 	return nil
 | |
| }
 |