about summary refs log tree commit diff
path: root/backend/is.go
blob: 01bc747c57d47b89383369ad570271c50b298fd0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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
}