storage

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 24, 2024 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultSqliteConfig = SqliteDatastoreConfig{
	DatabaseURL:        "file://./musclemem.sqlite",
	MigrationURL:       "file://./migrations/",
	Overwrite:          false,
	ForeignKeyEnforced: true,
}

Functions

This section is empty.

Types

type MockSqliteDatastore

type MockSqliteDatastore struct {
	*SqliteDatastore
}

func NewMockSqliteDatastore

func NewMockSqliteDatastore(t *testing.T) *MockSqliteDatastore

func (*MockSqliteDatastore) TablesEqual

func (ds *MockSqliteDatastore) TablesEqual(t *testing.T, wantTables []string) ([]string, bool)

func (*MockSqliteDatastore) WithExercise

func (ds *MockSqliteDatastore) WithExercise(t *testing.T, id int, workout int, name string, weight float64, reps int, prev int, next int)

func (*MockSqliteDatastore) WithUser

func (ds *MockSqliteDatastore) WithUser(t *testing.T, id int, email string, pass string)

func (*MockSqliteDatastore) WithWorkout

func (ds *MockSqliteDatastore) WithWorkout(t *testing.T, workoutID int, owner int, name string)

type SqliteDatastore

type SqliteDatastore struct {
	*sql.DB
}

func NewSqliteDatastore

func NewSqliteDatastore(config SqliteDatastoreConfig) (*SqliteDatastore, error)

NewSqliteDatastore creates a new database at dbURL and runs the migrations in the defaultMigrations folder if overwrite is false, it returns the existing db

func (*SqliteDatastore) CompileStatement

func (ds *SqliteDatastore) CompileStatement(stmt string, data any) (string, []any, error)

CompileStatement prepares a SQL statement using tqla.Template statement will be populated with the data argument like {{ .ID }}

type SqliteDatastoreConfig

type SqliteDatastoreConfig struct {
	DatabaseURL        string
	MigrationURL       string
	Overwrite          bool
	ForeignKeyEnforced bool
}

Configuration for SqliteDatastore

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL