diff options
Diffstat (limited to 'src/payload-processor/processor/db.go')
-rw-r--r-- | src/payload-processor/processor/db.go | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/payload-processor/processor/db.go b/src/payload-processor/processor/db.go index 607f97d..eb67a79 100644 --- a/src/payload-processor/processor/db.go +++ b/src/payload-processor/processor/db.go @@ -2,6 +2,7 @@ package processor import ( "context" + "log" "github.com/Baitinq/fs-tracer-backend/lib" "github.com/jmoiron/sqlx" @@ -25,8 +26,12 @@ func NewDB(db *sqlx.DB) DB { func (db DBImpl) InsertFiles(ctx context.Context, files []lib.File, user_id string) error { for _, file := range files { file.User_id = user_id + //TODO: Do bulk insert _, err := db.db.NamedExecContext(ctx, "INSERT INTO public.file (user_id, absolute_path, contents, timestamp) VALUES (:user_id, :absolute_path, :contents, :timestamp)", file) - return err + if err != nil { + return err + } + log.Println("Inserted file: ", file) } return nil } |