blob: ce7d5bbce6505cec5cd9c39bbc7e7d2291f5ebbc (
plain) (
tree)
|
|
package processor
import (
"context"
"github.com/jmoiron/sqlx"
)
//go:generate mockgen -source=$GOFILE -package=$GOPACKAGE -destination=mock_$GOFILE
type DB interface {
InsertFile(ctx context.Context, file File) error
}
type DBImpl struct {
db *sqlx.DB
}
var _ DB = (*DBImpl)(nil)
func NewDB(db *sqlx.DB) DB {
return &DBImpl{db: db}
}
func (db DBImpl) InsertFile(ctx context.Context, file File) error {
_, err := db.db.NamedExecContext(ctx, "INSERT INTO private.file (user_id, absolute_path, contents, timestamp) VALUES (:user_id, :absolute_path, :contents, :timestamp)", file)
return err
}
|