mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
@@ -61,6 +61,7 @@ var tables = [...]string{`CREATE TABLE IF NOT EXISTS routes (
|
||||
|
||||
`CREATE TABLE IF NOT EXISTS logs (
|
||||
id varchar(256) NOT NULL PRIMARY KEY,
|
||||
app_name varchar(256) NOT NULL,
|
||||
log text NOT NULL
|
||||
);`,
|
||||
}
|
||||
@@ -589,15 +590,15 @@ func (ds *sqlStore) GetCalls(ctx context.Context, filter *models.CallFilter) ([]
|
||||
return res, nil
|
||||
}
|
||||
|
||||
func (ds *sqlStore) InsertLog(ctx context.Context, callID, callLog string) error {
|
||||
query := ds.db.Rebind(`INSERT INTO logs (id, log) VALUES (?, ?);`)
|
||||
_, err := ds.db.ExecContext(ctx, query, callID, callLog)
|
||||
func (ds *sqlStore) InsertLog(ctx context.Context, appName, callID, callLog string) error {
|
||||
query := ds.db.Rebind(`INSERT INTO logs (id, app_name, log) VALUES (?, ?, ?);`)
|
||||
_, err := ds.db.ExecContext(ctx, query, callID, appName, callLog)
|
||||
return err
|
||||
}
|
||||
|
||||
func (ds *sqlStore) GetLog(ctx context.Context, callID string) (*models.CallLog, error) {
|
||||
query := ds.db.Rebind(`SELECT log FROM logs WHERE id=?`)
|
||||
row := ds.db.QueryRowContext(ctx, query, callID)
|
||||
func (ds *sqlStore) GetLog(ctx context.Context, appName, callID string) (*models.CallLog, error) {
|
||||
query := ds.db.Rebind(`SELECT log FROM logs WHERE id=? AND app_name=?`)
|
||||
row := ds.db.QueryRowContext(ctx, query, callID, appName)
|
||||
|
||||
var log string
|
||||
err := row.Scan(&log)
|
||||
@@ -614,9 +615,9 @@ func (ds *sqlStore) GetLog(ctx context.Context, callID string) (*models.CallLog,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (ds *sqlStore) DeleteLog(ctx context.Context, callID string) error {
|
||||
query := ds.db.Rebind(`DELETE FROM logs WHERE id=?`)
|
||||
_, err := ds.db.ExecContext(ctx, query, callID)
|
||||
func (ds *sqlStore) DeleteLog(ctx context.Context, appName, callID string) error {
|
||||
query := ds.db.Rebind(`DELETE FROM logs WHERE id=? AND app_name=?`)
|
||||
_, err := ds.db.ExecContext(ctx, query, callID, appName)
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user