switch namespaces from tags to relations with auto-creation
This commit is contained in:
12
db/rel.go
12
db/rel.go
@@ -32,3 +32,15 @@ func (db *DB) GetRelated(id string, r models.RelType) ([]string, error) {
|
||||
func (db *DB) GetIncomingRels(id string, r models.RelType) ([]string, error) {
|
||||
return getIDs(db, "SELECT from_id FROM rels WHERE to_id = ? AND rel_type = ?", id, r)
|
||||
}
|
||||
|
||||
func (db *DB) GetRelNames(n *models.Node, r models.RelType) ([]string, error) {
|
||||
result := make([]string, 0, len(n.Relations[string(r)]))
|
||||
for _, id := range n.Relations[string(r)] {
|
||||
node, err := db.NodeByID(id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
result = append(result, node.Title)
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user