fyp/logic/models/classes/data_point.go

24 lines
623 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) values ($1, $2, $3) 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
}