26 lines
413 B
Go
26 lines
413 B
Go
package store
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/glebarez/sqlite"
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
type sqliteStore struct {
|
|
db *gorm.DB
|
|
}
|
|
|
|
func NewSqliteStore(path string) (Store, error) {
|
|
db, err := gorm.Open(sqlite.Open(path))
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return &sqliteStore{db: db}, nil
|
|
}
|
|
|
|
func (s *sqliteStore) Session(ctx context.Context) *gorm.DB {
|
|
return s.db.Session(&gorm.Session{}).WithContext(ctx)
|
|
}
|