2026-03-26 12:48:47 +00:00
|
|
|
package db
|
|
|
|
|
|
|
|
|
|
import "axolotl/models"
|
|
|
|
|
|
2026-03-28 04:15:36 +01:00
|
|
|
func (db *DB) GetRelNames(n *models.Node, r models.RelType) ([]string, error) {
|
2026-03-29 18:58:34 +02:00
|
|
|
ids := n.Relations[string(r)]
|
|
|
|
|
if len(ids) == 0 {
|
|
|
|
|
return nil, nil
|
|
|
|
|
}
|
|
|
|
|
result := make([]string, 0, len(ids))
|
|
|
|
|
for _, id := range ids {
|
|
|
|
|
var title string
|
|
|
|
|
if err := db.QueryRow("SELECT title FROM nodes WHERE id = ?", id).Scan(&title); err != nil {
|
2026-03-28 04:15:36 +01:00
|
|
|
return nil, err
|
|
|
|
|
}
|
2026-03-29 18:58:34 +02:00
|
|
|
result = append(result, title)
|
2026-03-28 04:15:36 +01:00
|
|
|
}
|
|
|
|
|
return result, nil
|
|
|
|
|
}
|