29 lines
831 B
Go
29 lines
831 B
Go
package model_classes
|
|
|
|
import (
|
|
"database/sql"
|
|
"errors"
|
|
)
|
|
|
|
var FailedToGetIdAfterInsertError = errors.New("Failed to Get Id After Insert Error")
|
|
|
|
func AddDataPoint(db *sql.DB, class_id string, file_path string, mode DATA_POINT_MODE) (id string, err error) {
|
|
id = ""
|
|
result, err := db.Query("insert into model_data_point (class_id, file_path, model_mode, status) values ($1, $2, $3, 1) returning id;", class_id, file_path, mode)
|
|
if err != nil {
|
|
return
|
|
}
|
|
defer result.Close()
|
|
if !result.Next() {
|
|
err = FailedToGetIdAfterInsertError
|
|
return
|
|
}
|
|
err = result.Scan(&id)
|
|
return
|
|
}
|
|
|
|
func UpdateDataPointStatus(db *sql.DB, data_point_id string, status int, message *string) (err error) {
|
|
_, err = db.Exec("update model_data_point set status=$1, status_message=$2 where id=$3", status, message, data_point_id)
|
|
return
|
|
}
|