about summary refs log tree commit diff
path: root/backend/is.go
diff options
context:
space:
mode:
authorEmile <hanemile@protonmail.com>2019-03-07 16:14:12 +0100
committerEmile <hanemile@protonmail.com>2019-03-07 16:14:12 +0100
commitc8ca77ad65e9c0b31c6bd5289de0c1d332c06e63 (patch)
treeead406696f0c02a6b51e49a7dbcbbd1afce848c4 /backend/is.go
parent4d7880421ddc732d2f9fd3a2eaf1ca2c22a485c6 (diff)
subdivided the project into multiple logical compartments
Diffstat (limited to 'backend/is.go')
-rw-r--r--backend/is.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/backend/is.go b/backend/is.go
new file mode 100644
index 0000000..01bc747
--- /dev/null
+++ b/backend/is.go
@@ -0,0 +1,23 @@
+package backend
+
+import (
+	"fmt"
+	"log"
+)
+
+// isLeaf returns true if the node with the given id is a leaf
+func isLeaf(nodeID int64) bool {
+	var isLeaf bool
+
+	query := fmt.Sprintf("SELECT COALESCE(isleaf, FALSE) FROM nodes WHERE node_id=%d", nodeID)
+	err := db.QueryRow(query).Scan(&isLeaf)
+	if err != nil {
+		log.Fatalf("[ E ] isLeaf query: %v\n\t\t\t query: %s\n", err, query)
+	}
+
+	if isLeaf == true {
+		return true
+	}
+
+	return false
+}