Files
pages/internal/store/bookmark_children.go
Anya Tokugawa c1175d389f Implement Knowledge City platform, organizer and DAV integration
Capture accumulated application, UI, CLI, regression tests and design documentation changes, including task project mapping and default CalDAV list naming.

Keep deployment data, backups, local credentials and build artifacts out of Git. Move the Compose enrollment token to an ignored local environment file.
2026-09-27 14:44:43 +09:00

37 lines
1.0 KiB
Go

package store
import (
"context"
"strings"
)
func (s *Store) ListBookmarkChildren(ctx context.Context, domain, parent, after string) ([]string, bool, error) {
prefix := strings.TrimRight(parent, "/") + "/"
rows, err := s.DB.QueryContext(ctx, `WITH relative AS (
SELECT substr(path, length(?) + 1) AS suffix FROM paths
WHERE domain_uuid=? AND path>=? AND path<?
), children AS (
SELECT DISTINCT CASE WHEN instr(suffix,'/')=0 THEN suffix ELSE substr(suffix,1,instr(suffix,'/')-1) END AS name FROM relative
) SELECT name FROM children WHERE name > ? ORDER BY name LIMIT 81`, prefix, domain, prefix, strings.TrimSuffix(prefix, "/")+"0", after)
if err != nil {
return nil, false, err
}
defer rows.Close()
names := []string{}
for rows.Next() {
var name string
if err := rows.Scan(&name); err != nil {
return nil, false, err
}
names = append(names, name)
}
if err := rows.Err(); err != nil {
return nil, false, err
}
more := len(names) > 80
if more {
names = names[:80]
}
return names, more, nil
}