an app.bsky.* indexer
1package main
2
3type hostCursor struct {
4 ID int `gorm:"primaryKey"`
5 Host string
6 Cursor string
7}
8
9func (cs *CursorService) GetHostCursor(host string) (*hostCursor, error) {
10 var out hostCursor
11
12 if err := cs.store.Where(hostCursor{
13 Host: host,
14 }).Attrs(hostCursor{
15 Host: host,
16 Cursor: "",
17 }).FirstOrCreate(&out).Error; err != nil {
18 return nil, err
19 }
20
21 return &out, nil
22}
23
24func (cs *CursorService) SetHostCursor(host string, cursor string) error {
25 if err := cs.store.Model(&hostCursor{}).Where(hostCursor{
26 Host: host,
27 }).Update("cursor", cursor).Error; err != nil {
28 return err
29 }
30
31 return nil
32}