From c8ca77ad65e9c0b31c6bd5289de0c1d332c06e63 Mon Sep 17 00:00:00 2001 From: Emile Date: Thu, 7 Mar 2019 16:14:12 +0100 Subject: subdivided the project into multiple logical compartments --- backend/is.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 backend/is.go (limited to 'backend/is.go') 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 +} -- cgit 1.4.1