chore: split sql to driver (#2279)

* Add new database interface for SQL operations

* Move SQL code of Activity into Database

* Rename `Database` into `Driver`

* Move SQL code of SystemSetting into Driver

* Fix store.New in text code

* Change database into driver in the variables

* Change sqlite3.New into sqlite3.NewDriver
This commit is contained in:
Athurg Gooth
2023-09-26 17:16:58 +08:00
committed by GitHub
parent 85ed0202d8
commit 41eba71f0f
12 changed files with 145 additions and 74 deletions

View File

@@ -18,23 +18,5 @@ type Activity struct {
}
func (s *Store) CreateActivity(ctx context.Context, create *Activity) (*Activity, error) {
stmt := `
INSERT INTO activity (
creator_id,
type,
level,
payload
)
VALUES (?, ?, ?, ?)
RETURNING id, created_ts
`
if err := s.db.QueryRowContext(ctx, stmt, create.CreatorID, create.Type, create.Level, create.Payload).Scan(
&create.ID,
&create.CreatedTs,
); err != nil {
return nil, err
}
activity := create
return activity, nil
return s.driver.CreateActivity(ctx, create)
}