Documentation ¶
Index ¶
- type DataAccessLayer
- func (dal *DataAccessLayer) CreateSensor(tenantId int64, thingId int64, typeId int64) (*Sensor, error)
- func (dal *DataAccessLayer) CreateSensorTable(dropExistingTable bool)
- func (dal *DataAccessLayer) CreateThing(userId int64, name string, tenantId int64) (*Thing, error)
- func (dal *DataAccessLayer) CreateThingTable(dropExistingTable bool)
- func (dal *DataAccessLayer) CreateTimeSeriesDatum(tenantId int64, sensorId int64, value float64, timestamp int64) (*TimeSeriesDatum, error)
- func (dal *DataAccessLayer) CreateTimeSeriesDatumTable(dropExistingTable bool)
- func (dal *DataAccessLayer) CreateUser(email string, firstName string, lastName string, password string, ...) (*User, error)
- func (dal *DataAccessLayer) CreateUserTable(dropExistingTable bool)
- func (dal *DataAccessLayer) FindUserByEmail(email string) (*User, error)
- func (dal *DataAccessLayer) GetSensorByTenantIdAndCreatedAt(tenantId int64, createdAt int64) (*Sensor, error)
- func (dal *DataAccessLayer) GetThingByTenantIdAndCreatedAt(tenantId int64, createdAt int64) (*Thing, error)
- func (dal *DataAccessLayer) GetTimeSeriesDatumByTenantIdAndCreatedAt(tenantId int64, timestamp int64) (*TimeSeriesDatum, error)
- func (dal *DataAccessLayer) Shutdown()
- type Sensor
- type Thing
- type TimeSeriesDatum
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DataAccessLayer ¶
type DataAccessLayer struct {
// contains filtered or unexported fields
}
func InitDataAccessLayer ¶
func InitDataAccessLayer(dbHost, dbPort, dbUser, dbPassword, dbName string) *DataAccessLayer
*
- Function initializes our connection with the `postgres` database for this
- web-application and saves the db connection instance in a global variable.
func (*DataAccessLayer) CreateSensor ¶
func (dal *DataAccessLayer) CreateSensor(tenantId int64, thingId int64, typeId int64) (*Sensor, error)
*
- Function will create a sensor, if validation passess, and reutrns the `sensor`
- struct else returns the error.
func (*DataAccessLayer) CreateSensorTable ¶
func (dal *DataAccessLayer) CreateSensorTable(dropExistingTable bool)
*
- Function will create the `sensors` table in the database.
func (*DataAccessLayer) CreateThing ¶
*
- Function will create a thing, if validation passess, and reutrns the `thing`
- struct else returns the error.
func (*DataAccessLayer) CreateThingTable ¶
func (dal *DataAccessLayer) CreateThingTable(dropExistingTable bool)
*
- Function will create the `things` table in the database.
func (*DataAccessLayer) CreateTimeSeriesDatum ¶
func (dal *DataAccessLayer) CreateTimeSeriesDatum(tenantId int64, sensorId int64, value float64, timestamp int64) (*TimeSeriesDatum, error)
*
- Function will create a thing, if validation passess, and reutrns the `thing`
- struct else returns the error.
func (*DataAccessLayer) CreateTimeSeriesDatumTable ¶
func (dal *DataAccessLayer) CreateTimeSeriesDatumTable(dropExistingTable bool)
*
- Function will create the `data` table in the database.
func (*DataAccessLayer) CreateUser ¶
func (dal *DataAccessLayer) CreateUser(email string, firstName string, lastName string, password string, tenantId int64, tenantSchema string, roleId int64) (*User, error)
*
- Function will create a user, if validation passess, and reutrns the `user`
- struct else returns the error.
func (*DataAccessLayer) CreateUserTable ¶
func (dal *DataAccessLayer) CreateUserTable(dropExistingTable bool)
*
- Function will create the `users` table in the database.
func (*DataAccessLayer) FindUserByEmail ¶
func (dal *DataAccessLayer) FindUserByEmail(email string) (*User, error)
*
- Function will return the `user` struct if it exists in the database or
- return an error.
func (*DataAccessLayer) GetSensorByTenantIdAndCreatedAt ¶
func (dal *DataAccessLayer) GetSensorByTenantIdAndCreatedAt(tenantId int64, createdAt int64) (*Sensor, error)
*
- Function will return the `sensor` struct if it exists in the database or
- return an error.
func (*DataAccessLayer) GetThingByTenantIdAndCreatedAt ¶
func (dal *DataAccessLayer) GetThingByTenantIdAndCreatedAt(tenantId int64, createdAt int64) (*Thing, error)
*
- Function will return the `thing` struct if it exists in the database or
- return an error.
func (*DataAccessLayer) GetTimeSeriesDatumByTenantIdAndCreatedAt ¶
func (dal *DataAccessLayer) GetTimeSeriesDatumByTenantIdAndCreatedAt(tenantId int64, timestamp int64) (*TimeSeriesDatum, error)
*
- Function will return the `thing` struct if it exists in the database or
- return an error.
func (*DataAccessLayer) Shutdown ¶
func (dal *DataAccessLayer) Shutdown()
type TimeSeriesDatum ¶
type User ¶
type User struct { TenantId int64 `db:"tenant_id"` TenantSchema sql.NullString `db:"tenant_schema"` Id int64 `db:"id"` FirstName sql.NullString `db:"first_name"` LastName sql.NullString `db:"last_name"` PasswordHash sql.NullString `db:"password_hash"` Email sql.NullString `db:"email"` RoleId uint8 `db:"role_id"` }
Click to show internal directories.
Click to hide internal directories.