Documentation ¶
Overview ¶
Package repositories implements repositories for use in services.
Index ¶
- func NewDatabaseConnection(dsn string) (*gorm.DB, error)
- func NewDatabaseConnectionAndMigrate(ctx context.Context, dsn string) (db *gorm.DB, err error)
- type AccountModel
- type AccountRepository
- func (r *AccountRepository) Create(account account.Account) (account.Account, error)
- func (r *AccountRepository) Delete(account account.Account) error
- func (r *AccountRepository) Find(account account.Account) (account.Account, error)
- func (r *AccountRepository) GetAll() ([]account.Account, error)
- func (r *AccountRepository) Update(account account.Account) (account.Account, error)
- type AdminModel
- type AdminRepository
- func (r *AdminRepository) Create(admin admin.Admin) (admin.Admin, error)
- func (r *AdminRepository) Delete(admin admin.Admin) error
- func (r *AdminRepository) Find(admin admin.Admin) (admin.Admin, error)
- func (r *AdminRepository) GetAll() ([]admin.Admin, error)
- func (r *AdminRepository) Update(admin admin.Admin) (admin.Admin, error)
- type AppModel
- type AppRepository
- type BuildingModel
- type BuildingRepository
- func (r *BuildingRepository) Create(building building.Building) (building.Building, error)
- func (r *BuildingRepository) Delete(building building.Building) error
- func (r *BuildingRepository) Find(building building.Building) (building.Building, error)
- func (r *BuildingRepository) GetAll() ([]building.Building, error)
- type CampaignModel
- type CampaignRepository
- func (r *CampaignRepository) Create(campaign campaign.Campaign) (campaign.Campaign, error)
- func (r *CampaignRepository) Delete(campaign campaign.Campaign) error
- func (r *CampaignRepository) Find(campaign campaign.Campaign) (campaign.Campaign, error)
- func (r *CampaignRepository) GetAll() ([]campaign.Campaign, error)
- type CloudFeedAuthModel
- type CloudFeedAuthRepository
- func (r *CloudFeedAuthRepository) Create(cloudFeedAuth cloudfeedauth.CloudFeedAuth) (cloudfeedauth.CloudFeedAuth, error)
- func (r *CloudFeedAuthRepository) Delete(cloudFeedAuth cloudfeedauth.CloudFeedAuth) error
- func (r *CloudFeedAuthRepository) Find(cloudFeedAuth cloudfeedauth.CloudFeedAuth) (cloudfeedauth.CloudFeedAuth, error)
- func (r *CloudFeedAuthRepository) FindDevice(cloudFeedAuth cloudfeedauth.CloudFeedAuth) (*device.Device, error)
- func (r *CloudFeedAuthRepository) FindFirstTokenToExpire() (uint, uint, time.Time, error)
- func (r *CloudFeedAuthRepository) FindOAuthInfo(accountID uint, cloudFeedID uint) (string, string, string, string, error)
- func (r *CloudFeedAuthRepository) GetAll() ([]cloudfeedauth.CloudFeedAuth, error)
- func (r *CloudFeedAuthRepository) Update(cloudFeedAuth cloudfeedauth.CloudFeedAuth) (cloudfeedauth.CloudFeedAuth, error)
- type CloudFeedModel
- type CloudFeedRepository
- func (r *CloudFeedRepository) Create(cloudFeed cloudfeed.CloudFeed) (cloudfeed.CloudFeed, error)
- func (r *CloudFeedRepository) Delete(cloudFeed cloudfeed.CloudFeed) error
- func (r *CloudFeedRepository) Find(cloudFeed cloudfeed.CloudFeed) (cloudfeed.CloudFeed, error)
- func (r *CloudFeedRepository) GetAll() ([]cloudfeed.CloudFeed, error)
- func (r *CloudFeedRepository) Update(cloudFeed cloudfeed.CloudFeed) (cloudfeed.CloudFeed, error)
- type DeviceModel
- type DeviceRepository
- func (r *DeviceRepository) Create(device device.Device) (device.Device, error)
- func (r *DeviceRepository) Delete(device device.Device) error
- func (r *DeviceRepository) Find(device device.Device) (device.Device, error)
- func (r *DeviceRepository) FindCloudFeedAuthCreationTimeFromDeviceID(deviceID uint) (*time.Time, error)
- func (r *DeviceRepository) GetAll() ([]device.Device, error)
- func (r *DeviceRepository) GetMeasurements(device device.Device, filters map[string]string) ([]measurement.Measurement, error)
- func (r *DeviceRepository) GetProperties(device device.Device) ([]property.Property, error)
- func (r *DeviceRepository) Update(device device.Device) (device.Device, error)
- type DeviceTypeModel
- type DeviceTypeRepository
- func (r *DeviceTypeRepository) Create(deviceType devicetype.DeviceType) (devicetype.DeviceType, error)
- func (r *DeviceTypeRepository) Delete(deviceType devicetype.DeviceType) error
- func (r *DeviceTypeRepository) Find(deviceType devicetype.DeviceType) (devicetype.DeviceType, error)
- func (r *DeviceTypeRepository) GetAll() ([]devicetype.DeviceType, error)
- type MeasurementModel
- type PropertyModel
- type PropertyRepository
- func (r *PropertyRepository) Create(property property.Property) (property.Property, error)
- func (r *PropertyRepository) Delete(property property.Property) error
- func (r *PropertyRepository) Find(property property.Property) (property.Property, error)
- func (r *PropertyRepository) GetAll() ([]property.Property, error)
- type UploadModel
- type UploadRepository
- func (r *UploadRepository) Create(upload upload.Upload) (upload.Upload, error)
- func (r *UploadRepository) Delete(upload upload.Upload) error
- func (r *UploadRepository) Find(upload upload.Upload) (upload.Upload, error)
- func (r *UploadRepository) GetAll() ([]upload.Upload, error)
- func (r *UploadRepository) GetLatestUploadForDeviceWithID(id uint) (upload.Upload, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewDatabaseConnection ¶
Create a new database connection that can be used by repositories.
Types ¶
type AccountModel ¶
type AccountModel struct { gorm.Model CampaignModelID uint `gorm:"column:campaign_id"` Campaign CampaignModel ActivatedAt *time.Time Buildings []BuildingModel CloudFeedAuths []CloudFeedAuthModel `gorm:"foreignKey:AccountID"` }
Database representation of a account.Account.
func MakeAccountModel ¶
func MakeAccountModel(account account.Account) AccountModel
Create a new AccountModel from a account.Account.
func (AccountModel) TableName ¶
func (AccountModel) TableName() string
Set the name of the table in the database.
type AccountRepository ¶
type AccountRepository struct {
// contains filtered or unexported fields
}
func NewAccountRepository ¶
func NewAccountRepository(db *gorm.DB) *AccountRepository
func (*AccountRepository) Delete ¶
func (r *AccountRepository) Delete(account account.Account) error
type AdminModel ¶
type AdminModel struct { gorm.Model Name string `gorm:"unique;not null"` ActivatedAt time.Time Expiry time.Time }
Database representation of a admin.Admin.
func MakeAdminModel ¶
func MakeAdminModel(admin admin.Admin) AdminModel
Create a new AdminModel from a admin.Admin.
func (AdminModel) TableName ¶
func (AdminModel) TableName() string
Set the name of the table in the database.
type AdminRepository ¶
type AdminRepository struct {
// contains filtered or unexported fields
}
func NewAdminRepository ¶
func NewAdminRepository(fileName string) (*AdminRepository, error)
Create a new AdminRepository from a badger DB at fileName.
type AppModel ¶
type AppModel struct { gorm.Model Name string `gorm:"unique;not null"` ProvisioningURLTemplate string OauthRedirectURL string }
Database representation of a app.App.
type AppRepository ¶
type AppRepository struct {
// contains filtered or unexported fields
}
func NewAppRepository ¶
func NewAppRepository(db *gorm.DB) *AppRepository
type BuildingModel ¶
type BuildingModel struct { gorm.Model AccountModelID uint `gorm:"column:account_id"` Longtitude float32 Latitude float32 TZName string Devices []DeviceModel }
Database representation of a building.Building.
func MakeBuildingModel ¶
func MakeBuildingModel(building building.Building) BuildingModel
Create a new BuildingModel from a building.Building
func (BuildingModel) TableName ¶
func (BuildingModel) TableName() string
Set the name of the table in the database.
type BuildingRepository ¶
type BuildingRepository struct {
// contains filtered or unexported fields
}
func NewBuildingRepository ¶
func NewBuildingRepository(db *gorm.DB) *BuildingRepository
func (*BuildingRepository) Delete ¶
func (r *BuildingRepository) Delete(building building.Building) error
type CampaignModel ¶
type CampaignModel struct { gorm.Model Name string `gorm:"unique;not null"` AppModelID uint `gorm:"column:app_id"` App AppModel InfoURL string `gorm:"unique;not null"` CloudFeeds []CloudFeedModel `gorm:"many2many:campaign_cloud_feed"` StartTime *time.Time EndTime *time.Time }
Database representation of campaign.Campaign.
func MakeCampaignModel ¶
func MakeCampaignModel(campaign campaign.Campaign) CampaignModel
Create a new CampaignModel from a [twomes.campaign].
func (CampaignModel) TableName ¶
func (CampaignModel) TableName() string
Set the name of the table in the database.
type CampaignRepository ¶
type CampaignRepository struct {
// contains filtered or unexported fields
}
func NewCampaignRepository ¶
func NewCampaignRepository(db *gorm.DB) *CampaignRepository
func (*CampaignRepository) Delete ¶
func (r *CampaignRepository) Delete(campaign campaign.Campaign) error
type CloudFeedAuthModel ¶
type CloudFeedAuthModel struct { AccountID uint `gorm:"primaryKey;autoIncrement:false"` CloudFeedID uint `gorm:"primaryKey;autoIncrement:false"` CreatedAt time.Time UpdatedAt time.Time DeletedAt gorm.DeletedAt `gorm:"index"` // TODO: WARNING encrypted string encryption not yet implemented. AccessToken encryption.EncryptedString RefreshToken encryption.EncryptedString Expiry time.Time AuthGrantToken encryption.EncryptedString }
Database representation of cloudfeedauth.CloudFeedAuth.
func MakeCloudFeedAuthModel ¶
func MakeCloudFeedAuthModel(cloudFeedAuth cloudfeedauth.CloudFeedAuth) CloudFeedAuthModel
Create a new CloudFeedAuthModel from a [twomes.cloudFeedAuth].
func (CloudFeedAuthModel) TableName ¶
func (CloudFeedAuthModel) TableName() string
Set the name of the table in the database.
type CloudFeedAuthRepository ¶
type CloudFeedAuthRepository struct {
// contains filtered or unexported fields
}
func NewCloudFeedAuthRepository ¶
func NewCloudFeedAuthRepository(db *gorm.DB) *CloudFeedAuthRepository
func (*CloudFeedAuthRepository) Create ¶
func (r *CloudFeedAuthRepository) Create(cloudFeedAuth cloudfeedauth.CloudFeedAuth) (cloudfeedauth.CloudFeedAuth, error)
func (*CloudFeedAuthRepository) Delete ¶
func (r *CloudFeedAuthRepository) Delete(cloudFeedAuth cloudfeedauth.CloudFeedAuth) error
func (*CloudFeedAuthRepository) Find ¶
func (r *CloudFeedAuthRepository) Find(cloudFeedAuth cloudfeedauth.CloudFeedAuth) (cloudfeedauth.CloudFeedAuth, error)
func (*CloudFeedAuthRepository) FindDevice ¶
func (r *CloudFeedAuthRepository) FindDevice(cloudFeedAuth cloudfeedauth.CloudFeedAuth) (*device.Device, error)
func (*CloudFeedAuthRepository) FindFirstTokenToExpire ¶
func (*CloudFeedAuthRepository) FindOAuthInfo ¶
func (*CloudFeedAuthRepository) GetAll ¶
func (r *CloudFeedAuthRepository) GetAll() ([]cloudfeedauth.CloudFeedAuth, error)
func (*CloudFeedAuthRepository) Update ¶
func (r *CloudFeedAuthRepository) Update(cloudFeedAuth cloudfeedauth.CloudFeedAuth) (cloudfeedauth.CloudFeedAuth, error)
type CloudFeedModel ¶
type CloudFeedModel struct { gorm.Model Name string `gorm:"unique;not null"` AuthorizationURL string TokenURL string ClientID string // TODO: WARNING EncryptedString still has to implement the encryption. ClientSecret encryption.EncryptedString Scope string RedirectURL string CloudFeedAuths []CloudFeedAuthModel `gorm:"foreignKey:CloudFeedID"` }
Database representation of a cloudfeed.CloudFeed
func MakeCloudFeedModel ¶
func MakeCloudFeedModel(cloudFeed cloudfeed.CloudFeed) CloudFeedModel
Create a CloudFeedModel from a cloudfeed.CloudFeed.
func (CloudFeedModel) TableName ¶
func (CloudFeedModel) TableName() string
Set the name of the table in the database.
type CloudFeedRepository ¶
type CloudFeedRepository struct {
// contains filtered or unexported fields
}
func NewCloudFeedRepository ¶
func NewCloudFeedRepository(db *gorm.DB) *CloudFeedRepository
Create a new CloudFeedRepository.
func (*CloudFeedRepository) Delete ¶
func (r *CloudFeedRepository) Delete(cloudFeed cloudfeed.CloudFeed) error
type DeviceModel ¶
type DeviceModel struct { gorm.Model Name string `gorm:"unique;not null"` DeviceTypeModelID uint `gorm:"column:device_type_id"` DeviceType DeviceTypeModel BuildingModelID uint `gorm:"column:building_id"` ActivationSecretHash string ActivatedAt *time.Time Uploads []UploadModel }
Database representation of a device.Device
func MakeDeviceModel ¶
func MakeDeviceModel(device device.Device) DeviceModel
Create a DeviceModel from a device.Device.
func (DeviceModel) TableName ¶
func (DeviceModel) TableName() string
Set the name of the table in the database.
type DeviceRepository ¶
type DeviceRepository struct {
// contains filtered or unexported fields
}
func NewDeviceRepository ¶
func NewDeviceRepository(db *gorm.DB) *DeviceRepository
Create a new DeviceRepository.
func (*DeviceRepository) FindCloudFeedAuthCreationTimeFromDeviceID ¶
func (r *DeviceRepository) FindCloudFeedAuthCreationTimeFromDeviceID(deviceID uint) (*time.Time, error)
func (*DeviceRepository) GetMeasurements ¶
func (r *DeviceRepository) GetMeasurements(device device.Device, filters map[string]string) ([]measurement.Measurement, error)
func (*DeviceRepository) GetProperties ¶
type DeviceTypeModel ¶
type DeviceTypeModel struct { gorm.Model Name string `gorm:"unique;non null"` InstallationManualURL string InfoURL string }
Database representation of a devicetype.DeviceType
func MakeDeviceTypeModel ¶
func MakeDeviceTypeModel(deviceType devicetype.DeviceType) DeviceTypeModel
Create a DeviceTypeModel from a devicetype.DeviceType.
func (DeviceTypeModel) TableName ¶
func (DeviceTypeModel) TableName() string
Set the name of the table in the database.
type DeviceTypeRepository ¶
type DeviceTypeRepository struct {
// contains filtered or unexported fields
}
func NewDeviceTypeRepository ¶
func NewDeviceTypeRepository(db *gorm.DB) *DeviceTypeRepository
Create a new DeviceTypeRepository.
func (*DeviceTypeRepository) Create ¶
func (r *DeviceTypeRepository) Create(deviceType devicetype.DeviceType) (devicetype.DeviceType, error)
func (*DeviceTypeRepository) Delete ¶
func (r *DeviceTypeRepository) Delete(deviceType devicetype.DeviceType) error
func (*DeviceTypeRepository) Find ¶
func (r *DeviceTypeRepository) Find(deviceType devicetype.DeviceType) (devicetype.DeviceType, error)
func (*DeviceTypeRepository) GetAll ¶
func (r *DeviceTypeRepository) GetAll() ([]devicetype.DeviceType, error)
type MeasurementModel ¶
type MeasurementModel struct { gorm.Model PropertyModelID uint `gorm:"column:property_id"` Property PropertyModel UploadModelID uint `gorm:"column:upload_id"` Time time.Time Value string }
Database representation of a measurement.Measurement
func MakeMeasurementModel ¶
func MakeMeasurementModel(measurement measurement.Measurement) MeasurementModel
Create a MeasurementModel from a measurement.Measurement.
func (MeasurementModel) TableName ¶
func (MeasurementModel) TableName() string
Set the name of the table in the database.
type PropertyModel ¶
Database representation of a property.Property
func MakePropertyModel ¶
func MakePropertyModel(property property.Property) PropertyModel
Create a PropertyModel from a property.Property.
func (PropertyModel) TableName ¶
func (PropertyModel) TableName() string
Set the name of the table in the database.
type PropertyRepository ¶
type PropertyRepository struct {
// contains filtered or unexported fields
}
func NewPropertyRepository ¶
func NewPropertyRepository(db *gorm.DB) *PropertyRepository
Create a new PropertyRepository.
func (*PropertyRepository) Delete ¶
func (r *PropertyRepository) Delete(property property.Property) error
type UploadModel ¶
type UploadModel struct { gorm.Model DeviceModelID uint `gorm:"column:device_id"` ServerTime time.Time DeviceTime time.Time Size int Measurements []MeasurementModel }
Database representation of a upload.Upload
func MakeUploadModel ¶
func MakeUploadModel(upload upload.Upload) UploadModel
Create an UploadModel from a upload.Upload.
func (UploadModel) TableName ¶
func (UploadModel) TableName() string
Set the name of the table in the database.
type UploadRepository ¶
type UploadRepository struct {
// contains filtered or unexported fields
}
func NewUploadRepository ¶
func NewUploadRepository(db *gorm.DB) *UploadRepository
Create a new UploadRepository.
func (*UploadRepository) GetLatestUploadForDeviceWithID ¶
func (r *UploadRepository) GetLatestUploadForDeviceWithID(id uint) (upload.Upload, error)