models

package
v0.0.0-...-1f8c64b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 10, 2019 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

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

func (dal *DataAccessLayer) CreateThing(userId int64, name string, tenantId int64) (*Thing, error)

*

  • 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 Sensor

type Sensor struct {
	Id        int64 `db:"id"`
	TenantId  int64 `db:"tenant_id"`
	ThingId   int64 `db:"thing_id"`
	TypeId    uint8 `db:"type_id"`
	CreatedAt int64 `db:"created_at"`
}

type Thing

type Thing struct {
	Id        int64          `db:"id"`
	TenantId  int64          `db:"tenant_id"`
	UserId    uint8          `db:"user_id"`
	Name      sql.NullString `db:"name"`
	CreatedAt int64          `db:"created_at"`
}

type TimeSeriesDatum

type TimeSeriesDatum struct {
	Id        int64   `db:"id"`
	TenantId  int64   `db:"tenant_id"`
	SensorId  int64   `db:"sensor_id"`
	Value     float64 `db:"value"`
	Timestamp int64   `db:"timestamp"`
}

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"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL