Documentation ¶
Index ¶
- Variables
- func CreateRecord(db *mongo.Database, collection string, data MQTTRecord) error
- func GetDB(uri string, db string) (*mongo.Database, error)
- func GetOptions(page int64, isDescend bool) *options.FindOptions
- func HandleMQTTtoDB(mqttToDb chan MQTTMsg, db *mongo.Database)
- type MQTTMsg
- type MQTTRecord
- func GetRecords(db *mongo.Database, collection string, filter interface{}, ...) ([]MQTTRecord, error)
- func GetRecordsBetween(db *mongo.Database, collection string, start time.Time, end time.Time, ...) ([]MQTTRecord, error)
- func GetRecordsByPage(db *mongo.Database, collection string, page int64) ([]MQTTRecord, error)
- func GetRecordsFrom(db *mongo.Database, collection string, start time.Time, page int64, ...) ([]MQTTRecord, error)
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 GetOptions ¶
func GetOptions(page int64, isDescend bool) *options.FindOptions
func HandleMQTTtoDB ¶
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 GetRecordsByPage ¶
Click to show internal directories.
Click to hide internal directories.