package postgres import ( "context" ) const ( tbstation = "public.station" ) type station struct { ID int64 `gorm:"colunmn:id"` ZoneID int64 `gorm:"colunmn:zone_id"` TagName string `gorm:"column:tagname"` Name string `gorm:"colunmn:name"` IsLocal bool `gorm:"colunmn:is_local"` } func GetStations(ctx context.Context) ([]*station, error) { var records []*station result := client.WithContext(ctx).Table(tbstation).Find(&records) if result.Error != nil { return nil, result.Error } return records, nil } func GetLocalStation(ctx context.Context) (*station, error) { var record *station result := client.WithContext(ctx).Table(tbstation).Where("is_local=?", true).Find(&record) if result.Error != nil { return nil, result.Error } return record, nil }