-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
notification.go
42 lines (34 loc) · 1.16 KB
/
notification.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package dao
import (
"github.com/chroma-core/chroma/go/pkg/metastore/db/dbmodel"
"gorm.io/gorm"
)
type notificationDb struct {
db *gorm.DB
}
var _ dbmodel.INotificationDb = ¬ificationDb{}
func (s *notificationDb) DeleteAll() error {
return s.db.Where("1 = 1").Delete(&dbmodel.Notification{}).Error
}
func (s *notificationDb) Delete(id []int64) error {
return s.db.Where("id IN ?", id).Delete(&dbmodel.Notification{}).Error
}
func (s *notificationDb) Insert(in *dbmodel.Notification) error {
return s.db.Create(in).Error
}
func (s *notificationDb) GetNotificationByCollectionID(collectionID string) ([]*dbmodel.Notification, error) {
var notifications []*dbmodel.Notification
err := s.db.Where("collection_id = ? AND status = ?", collectionID, dbmodel.NotificationStatusPending).Find(¬ifications).Error
if err != nil {
return nil, err
}
return notifications, nil
}
func (s *notificationDb) GetAllPendingNotifications() ([]*dbmodel.Notification, error) {
var notifications []*dbmodel.Notification
err := s.db.Where("status = ?", dbmodel.NotificationStatusPending).Find(¬ifications).Error
if err != nil {
return nil, err
}
return notifications, nil
}