about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorEmile <hanemile@protonmail.com>2019-10-19 21:19:10 +0200
committerEmile <hanemile@protonmail.com>2019-10-19 21:19:10 +0200
commit71b82eca41b89437dbed7a80b3bf620cd6c0a074 (patch)
tree4fe72ea015d3bce7d0c00b78a3a2ca9f77d3d39d /src
parentfcbde6b1ae0fcf4e531d0760a091a33c6b63e8ea (diff)
edit challenge function
Diffstat (limited to 'src')
-rw-r--r--src/db.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/db.go b/src/db.go
index 6961aad..3238bf2 100644
--- a/src/db.go
+++ b/src/db.go
@@ -95,3 +95,14 @@ func dbNewChallenge(challenge Challenge) (string, error) {
 	}
 	return uuid, nil
 }
+
+// editChallengeUUID edited the challenge with the given uuid using the values in the updatedChallenge
+func editChallengeUUID(uuid string, updatedChallenge Challenge) error {
+	query := fmt.Sprintf("UPDATE challenges SET name = '%s', description = '%s', flag = '%s', container = '%s', category = '%s', points = %d, static = %t WHERE uuid::text = '%s'", updatedChallenge.Name, updatedChallenge.Description, updatedChallenge.Flag, updatedChallenge.Container, updatedChallenge.Category, updatedChallenge.Points, updatedChallenge.Static, updatedChallenge.UUID)
+
+	fmt.Printf("Query: %s", query)
+
+	_, _ = db.Exec(query)
+
+	return nil
+}