-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
190 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,20 @@ | ||
package datastore | ||
|
||
import ( | ||
"errors" | ||
"context" | ||
|
||
"github.com/flohansen/dasher-server/internal/model" | ||
"github.com/flohansen/dasher-server/internal/sqlc" | ||
) | ||
|
||
type InMemDatastore struct { | ||
type SQLiteDatastore struct { | ||
q *sqlc.Queries | ||
} | ||
|
||
func NewInMem() *InMemDatastore { | ||
return &InMemDatastore{} | ||
func NewSQLite(db sqlc.DBTX) *SQLiteDatastore { | ||
q := sqlc.New(db) | ||
return &SQLiteDatastore{q} | ||
} | ||
|
||
func (repo *InMemDatastore) GetAll() ([]model.FeatureData, error) { | ||
return nil, errors.New("not implemented") | ||
func (repo *SQLiteDatastore) GetAll(ctx context.Context) ([]sqlc.Feature, error) { | ||
return repo.q.GetAllFeatures(ctx) | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
begin; | ||
|
||
drop table if exists features; | ||
|
||
commit; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
begin; | ||
|
||
create table if not exists features ( | ||
feature_id text not null primary key, | ||
description text, | ||
enabled tinyint | ||
); | ||
|
||
commit; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
-- name: GetAllFeatures :many | ||
select * from features; | ||
|
||
-- name: UpsertFeature :exec | ||
insert into features (feature_id, description, enabled) | ||
values (?, ?, ?) | ||
on conflict (feature_id) do update set | ||
description = excluded.description, | ||
enabled = excluded.enabled | ||
returning *; | ||
|
||
-- name: DeleteFeature :exec | ||
delete from features where feature_id = ?; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
version: "2" | ||
sql: | ||
- schema: "migrations" | ||
queries: "queries" | ||
engine: sqlite | ||
gen: | ||
go: | ||
package: "sqlc" | ||
out: "internal/sqlc" |