about summary refs log tree commit diff
path: root/src/payload-processor/processor/db.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/payload-processor/processor/db.go')
-rw-r--r--src/payload-processor/processor/db.go13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/payload-processor/processor/db.go b/src/payload-processor/processor/db.go
index 2200937..f8c4619 100644
--- a/src/payload-processor/processor/db.go
+++ b/src/payload-processor/processor/db.go
@@ -9,7 +9,7 @@ import (
 
 //go:generate mockgen -source=$GOFILE -package=$GOPACKAGE -destination=mock_$GOFILE
 type DB interface {
-	InsertFile(ctx context.Context, file lib.File, user_id string) error
+	InsertFiles(ctx context.Context, files []lib.File, user_id string) error
 }
 
 type DBImpl struct {
@@ -22,8 +22,11 @@ func NewDB(db *sqlx.DB) DB {
 	return &DBImpl{db: db}
 }
 
-func (db DBImpl) InsertFile(ctx context.Context, file lib.File, user_id string) error {
-	file.User_id = user_id
-	_, 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
+func (db DBImpl) InsertFiles(ctx context.Context, files []lib.File, user_id string) error {
+	for _, file := range files {
+		file.User_id = user_id
+		_, 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
+	}
+	return nil
 }