package storage import ( "gorm.io/gorm" "unifiedpush.org/go/np2p_dbus/storage" ) func InitStorage(path string) (*Storage, error) { st, err := storage.InitStorage(path) db := st.DB() if err := db.AutoMigrate(&latestID{}); err != nil { return nil, err } return &Storage{Storage: st, db: st.DB()}, err } type Storage struct { *storage.Storage db *gorm.DB } func (d Storage) GetLatestNotif() (int64, error) { id := latestID{} result := d.db.First(&id) return id.ID, result.Error } func (d Storage) SaveLatestNotif(time int64) error { id := latestID{} result := d.db.Model(&id).Where("1=1").Update("id", time) return result.Error } type latestID struct { ID int64 }