diff options
Diffstat (limited to 'backend/is.go')
-rw-r--r-- | backend/is.go | 23 |
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 +} |