model

package
v0.0.0-...-f03831e Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2022 License: MPL-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Ctx = context.TODO()
)

Functions

func CreateRecord

func CreateRecord(db *mongo.Database, collection string, data MQTTRecord) error

func GetDB

func GetDB(uri string, db string) (*mongo.Database, error)

func GetOptions

func GetOptions(page int64, isDescend bool) *options.FindOptions

func HandleMQTTtoDB

func HandleMQTTtoDB(mqttToDb chan MQTTMsg, db *mongo.Database)

Types

type MQTTMsg

type MQTTMsg struct {
	Topic   string `json:"topic" example:"temperature"`
	Payload string `json:"payload" example:"23.5"`
}

func (*MQTTMsg) ToRecord

func (m *MQTTMsg) ToRecord() (MQTTRecord, error)

type MQTTRecord

type MQTTRecord struct {
	Payload float64 `bson:"payload" json:"payload" example:"24.23"`
	// Time RFC3339
	Timestamp time.Time `bson:"timestamp" json:"timestamp" example:"2020-01-01T00:00:00Z"`
}

func GetRecords

func GetRecords(db *mongo.Database, collection string, filter interface{}, opts *options.FindOptions) ([]MQTTRecord, error)

func GetRecordsBetween

func GetRecordsBetween(db *mongo.Database, collection string, start time.Time, end time.Time, page int64, isDescend bool) ([]MQTTRecord, error)

func GetRecordsByPage

func GetRecordsByPage(db *mongo.Database, collection string, page int64) ([]MQTTRecord, error)

func GetRecordsFrom

func GetRecordsFrom(db *mongo.Database, collection string, start time.Time, page int64, isDescend bool) ([]MQTTRecord, error)

Jump to

Keyboard shortcuts

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