Subcategory now accepts POST requests, so they can be added even after a category has been created.
This commit is contained in:
+17
@@ -195,3 +195,20 @@ func getSubcategories(categoryID int64) (subcategories []Subcategory, ok bool) {
|
||||
|
||||
return subcategories, true
|
||||
}
|
||||
|
||||
func insertSubcategory(name string, categoryID int64) (recordID int64, ok bool) {
|
||||
db := getSQLConnection()
|
||||
|
||||
defer db.Close()
|
||||
|
||||
err := db.QueryRow("INSERT INTO subcategory(subcategory_name, category_id) VALUES($1, $2) RETURNING subcategory_id;", name, categoryID).Scan(&recordID)
|
||||
|
||||
if err != nil {
|
||||
//TODO: log this error
|
||||
println(err.Error())
|
||||
return 0, false
|
||||
//panic(err)
|
||||
}
|
||||
|
||||
return recordID, true
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user