mirror of
https://github.com/usememos/memos.git
synced 2025-01-17 18:11:48 +08:00
41eba71f0f
* 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
28 lines
523 B
Go
28 lines
523 B
Go
package sqlite3
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/usememos/memos/store"
|
|
)
|
|
|
|
func (d *Driver) CreateActivity(ctx context.Context, create *store.Activity) (*store.Activity, error) {
|
|
stmt := `
|
|
INSERT INTO activity (
|
|
creator_id,
|
|
type,
|
|
level,
|
|
payload
|
|
)
|
|
VALUES (?, ?, ?, ?)
|
|
RETURNING id, created_ts
|
|
`
|
|
if err := d.db.QueryRowContext(ctx, stmt, create.CreatorID, create.Type, create.Level, create.Payload).Scan(
|
|
&create.ID,
|
|
&create.CreatedTs,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return create, nil
|
|
}
|