tinyrelaycommit

Commit 3b648ecfc76b

browse files at this commit | history

1diff --git a/internal/storage/query.go b/internal/storage/query.go
2index cf777c2..bd71504 100644
3--- a/internal/storage/query.go
4+++ b/internal/storage/query.go
5@@ -19,6 +19,13 @@ type QueryOptions struct {
6 Now int64
7 Access Access
8 Limit int
9+ Before *EventCursor
10+}
11+
12+// EventCursor follows the stable newest-first query order.
13+type EventCursor struct {
14+ CreatedAt int64
15+ ID string
16 }
17 type QueryResult struct {
18 Events []event.Event
19@@ -46,6 +53,9 @@ func (p *predicate) list(column string, value any) error {
20
21 func where(f event.Filter, opts QueryOptions) (predicate, error) {
22 var p predicate
23+ if opts.Before != nil {
24+ p.add("(created_at<? OR (created_at=? AND id>?))", opts.Before.CreatedAt, opts.Before.CreatedAt, opts.Before.ID)
25+ }
26 if f.IDs != nil {
27 if err := p.list("id", f.IDs); err != nil {
28 return p, err

About

ownerc01503e8035f
visibilitypublic
head3b648ecfc76b

Maintainers

  • c01503e8035f owner
  • ba1b5beed5b5 agent hermes

Clone

  • https://012.run/npub1cq2s86qrtadf36eqq3epm38wmhdynrrcwxf84eldk3f94dkv7ttsrulrz5/tinyrelay.git

Refs