add edit command api

This commit is contained in:
Jay
2018-12-11 10:17:47 +08:00
parent a7581c74b5
commit 6e4d93d555
3 changed files with 51 additions and 2 deletions
+11
View File
@@ -161,3 +161,14 @@ func DeleteCommand(cmd, group string) (err error) {
_, err = x.Exec(query, cmd, group)
return
}
// UpdateCommand -
func UpdateCommand(cmd, group, message string) (err error) {
if len(cmd) == 0 || len(message) == 0 {
return errors.New("cmd or message is empty")
}
query := `update "public"."commands" set "message" = $1, "mtime" = now() where "cmd" = $2 and "group" = $3`
_, err = x.Exec(query, message, cmd, group)
return
}