dtclient

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2019 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//DeviceTableName device table
	DeviceTableName = "device"
	//DeviceAttrTableName device table
	DeviceAttrTableName = "device_attr"
	//DeviceTwinTableName device table
	DeviceTwinTableName = "device_twin"
)
View Source
const (
	//TwinTableName twin table name
	TwinTableName = "twin"
)

Variables

This section is empty.

Functions

func AddDeviceTrans

func AddDeviceTrans(adds []Device, addAttrs []DeviceAttr, addTwins []DeviceTwin) error

AddDeviceTrans the transaction of add device

func DeleteDeviceAttr

func DeleteDeviceAttr(deviceID string, name string) error

DeleteDeviceAttr delete device attr

func DeleteDeviceAttrByDeviceID

func DeleteDeviceAttrByDeviceID(deviceID string) error

DeleteDeviceAttrByDeviceID delete device attr

func DeleteDeviceByID

func DeleteDeviceByID(id string) error

DeleteDeviceByID delete device by id

func DeleteDeviceTrans

func DeleteDeviceTrans(deletes []string) error

DeleteDeviceTrans the transaction of delete device

func DeleteDeviceTwin

func DeleteDeviceTwin(deviceID string, name string) error

DeleteDeviceTwin delete device twin

func DeleteDeviceTwinByDeviceID

func DeleteDeviceTwinByDeviceID(deviceID string) error

DeleteDeviceTwinByDeviceID delete device twin

func DeleteTwinByID

func DeleteTwinByID(id string) error

DeleteTwinByID delete twin

func DeviceAttrTrans

func DeviceAttrTrans(adds []DeviceAttr, deletes []DeviceDelete, updates []DeviceAttrUpdate) error

DeviceAttrTrans transaction of device attr

func DeviceTwinTrans

func DeviceTwinTrans(adds []DeviceTwin, deletes []DeviceDelete, updates []DeviceTwinUpdate) error

DeviceTwinTrans transaction of device twin

func InitDBTable

func InitDBTable()

InitDBTable create table

func QueryDevice

func QueryDevice(key string, condition string) (*[]Device, error)

QueryDevice query Device

func QueryDeviceAll

func QueryDeviceAll() (*[]Device, error)

QueryDeviceAll query twin

func QueryDeviceAttr

func QueryDeviceAttr(key string, condition string) (*[]DeviceAttr, error)

QueryDeviceAttr query Device

func QueryDeviceTwin

func QueryDeviceTwin(key string, condition string) (*[]DeviceTwin, error)

QueryDeviceTwin query Device

func QueryTwin

func QueryTwin(key string, condition string) (*[]Twin, error)

QueryTwin query twin

func QueryTwinAll

func QueryTwinAll() (*[]Twin, error)

QueryTwinAll query twin

func SaveDevice

func SaveDevice(doc *Device) error

SaveDevice save device

func SaveDeviceAttr

func SaveDeviceAttr(doc *DeviceAttr) error

SaveDeviceAttr save device attributes

func SaveDeviceTwin

func SaveDeviceTwin(doc *DeviceTwin) error

SaveDeviceTwin save device twin

func SaveTwin

func SaveTwin(doc *Twin) error

SaveTwin save twin

func UpdateDeviceAttrField

func UpdateDeviceAttrField(deviceID string, name string, col string, value interface{}) error

UpdateDeviceAttrField update special field

func UpdateDeviceAttrFields

func UpdateDeviceAttrFields(deviceID string, name string, cols map[string]interface{}) error

UpdateDeviceAttrFields update special fields

func UpdateDeviceAttrMulti

func UpdateDeviceAttrMulti(updates []DeviceAttrUpdate) error

UpdateDeviceAttrMulti update device attr multi

func UpdateDeviceField

func UpdateDeviceField(deviceID string, col string, value interface{}) error

UpdateDeviceField update special field

func UpdateDeviceFields

func UpdateDeviceFields(deviceID string, cols map[string]interface{}) error

UpdateDeviceFields update special fields

func UpdateDeviceMulti

func UpdateDeviceMulti(updates []DeviceUpdate) error

UpdateDeviceMulti update device multi

func UpdateDeviceTwinField

func UpdateDeviceTwinField(deviceID string, name string, col string, value interface{}) error

UpdateDeviceTwinField update special field

func UpdateDeviceTwinFields

func UpdateDeviceTwinFields(deviceID string, name string, cols map[string]interface{}) error

UpdateDeviceTwinFields update special fields

func UpdateDeviceTwinMulti

func UpdateDeviceTwinMulti(updates []DeviceTwinUpdate) error

UpdateDeviceTwinMulti update device twin multi

func UpdateTwinField

func UpdateTwinField(deviceID string, col string, value interface{}) error

UpdateTwinField update special field

func UpdateTwinFields

func UpdateTwinFields(deviceID string, cols map[string]interface{}) error

UpdateTwinFields update special fields

Types

type Device

type Device struct {
	ID          string `orm:"column(id); size(64); pk"`
	Name        string `orm:"column(name); null; type(text)"`
	Description string `orm:"column(description); null; type(text)"`
	State       string `orm:"column(state); null; type(text)"`
	LastOnline  string `orm:"column(last_online); null; type(text)"`
}

Device the struct of device

type DeviceAttr

type DeviceAttr struct {
	ID          int64  `orm:"column(id);size(64);auto;pk"`
	DeviceID    string `orm:"column(deviceid); null; type(text)"`
	Name        string `orm:"column(name);null;type(text)"`
	Description string `orm:"column(description);null;type(text)"`
	Value       string `orm:"column(value);null;type(text)"`
	Optional    bool   `orm:"column(optional);null;type(integer)"`
	AttrType    string `orm:"column(attr_type);null;type(text)"`
	Metadata    string `orm:"column(metadata);null;type(text)"`
}

DeviceAttr the struct of device attributes

type DeviceAttrUpdate

type DeviceAttrUpdate struct {
	DeviceID string
	Name     string
	Cols     map[string]interface{}
}

DeviceAttrUpdate the struct for updating device attr

type DeviceDelete

type DeviceDelete struct {
	DeviceID string
	Name     string
}

DeviceDelete the struct for deleting device

type DeviceTwin

type DeviceTwin struct {
	ID              int64  `orm:"column(id);size(64);auto;pk"`
	DeviceID        string `orm:"column(deviceid); null; type(text)"`
	Name            string `orm:"column(name);null;type(text)"`
	Description     string `orm:"column(description);null;type(text)"`
	Expected        string `orm:"column(expected);null;type(text)"`
	Actual          string `orm:"column(actual);null;type(text)"`
	ExpectedMeta    string `orm:"column(expected_meta);null;type(text)"`
	ActualMeta      string `orm:"column(actual_meta);null;type(text)"`
	ExpectedVersion string `orm:"column(expected_version);null;type(text)"`
	ActualVersion   string `orm:"column(actual_version);null;type(text)"`
	Optional        bool   `orm:"column(optional);null;type(integer)"`
	AttrType        string `orm:"column(attr_type);null;type(text)"`
	Metadata        string `orm:"column(metadata);null;type(text)"`
}

DeviceTwin the struct of device twin

type DeviceTwinUpdate

type DeviceTwinUpdate struct {
	DeviceID string
	Name     string
	Cols     map[string]interface{}
}

DeviceTwinUpdate the struct for updating device twin

type DeviceUpdate

type DeviceUpdate struct {
	DeviceID string
	Cols     map[string]interface{}
}

DeviceUpdate the struct for updating device

type Twin

type Twin struct {
	// ID    int64  `orm:"pk; auto; column(id)"`
	DeviceID   string `orm:"column(deviceid); size(64); pk"`
	DeviceName string `orm:"column(devicename); null; type(text)"`
	Expected   string `orm:"column(expected); null; type(text)"`
	Actual     string `orm:"column(actual); null; type(text)"`
	Metadata   string `orm:"column(metadata); null; type(text)"`
	LastState  string `orm:"column(laststate); null; type(text)"`
	Attributes string `orm:"column(attributes); null; type(text)"`
	VersionSet string `orm:"column(versionset); null; type(text)"`
}

Twin object

Jump to

Keyboard shortcuts

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