iot

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2019 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EventBinding = event_EntityInfo{
	Entity: objectbox.Entity{
		Id: 1,
	},
	Uid: 1468539308767086854,
}
View Source
var Event_ = struct {
	Id      *objectbox.PropertyUint64
	Uid     *objectbox.PropertyString
	Device  *objectbox.PropertyString
	Date    *objectbox.PropertyInt64
	Picture *objectbox.PropertyByteVector
}{
	Id: &objectbox.PropertyUint64{
		BaseProperty: &objectbox.BaseProperty{
			Id:     1,
			Entity: &EventBinding.Entity,
		},
	},
	Uid: &objectbox.PropertyString{
		BaseProperty: &objectbox.BaseProperty{
			Id:     4,
			Entity: &EventBinding.Entity,
		},
	},
	Device: &objectbox.PropertyString{
		BaseProperty: &objectbox.BaseProperty{
			Id:     2,
			Entity: &EventBinding.Entity,
		},
	},
	Date: &objectbox.PropertyInt64{
		BaseProperty: &objectbox.BaseProperty{
			Id:     3,
			Entity: &EventBinding.Entity,
		},
	},
	Picture: &objectbox.PropertyByteVector{
		BaseProperty: &objectbox.BaseProperty{
			Id:     5,
			Entity: &EventBinding.Entity,
		},
	},
}

Event_ contains type-based Property helpers to facilitate some common operations such as Queries.

View Source
var ReadingBinding = reading_EntityInfo{
	Entity: objectbox.Entity{
		Id: 2,
	},
	Uid: 5284076134434938613,
}
View Source
var Reading_ = struct {
	Id              *objectbox.PropertyUint64
	Date            *objectbox.PropertyInt64
	EventId         *objectbox.RelationToOne
	ValueName       *objectbox.PropertyString
	ValueString     *objectbox.PropertyString
	ValueInteger    *objectbox.PropertyInt64
	ValueFloating   *objectbox.PropertyFloat64
	ValueInt32      *objectbox.PropertyInt32
	ValueFloating32 *objectbox.PropertyFloat32
}{
	Id: &objectbox.PropertyUint64{
		BaseProperty: &objectbox.BaseProperty{
			Id:     1,
			Entity: &ReadingBinding.Entity,
		},
	},
	Date: &objectbox.PropertyInt64{
		BaseProperty: &objectbox.BaseProperty{
			Id:     2,
			Entity: &ReadingBinding.Entity,
		},
	},
	EventId: &objectbox.RelationToOne{
		Property: &objectbox.BaseProperty{
			Id:     3,
			Entity: &ReadingBinding.Entity,
		},
		Target: &EventBinding.Entity,
	},
	ValueName: &objectbox.PropertyString{
		BaseProperty: &objectbox.BaseProperty{
			Id:     4,
			Entity: &ReadingBinding.Entity,
		},
	},
	ValueString: &objectbox.PropertyString{
		BaseProperty: &objectbox.BaseProperty{
			Id:     5,
			Entity: &ReadingBinding.Entity,
		},
	},
	ValueInteger: &objectbox.PropertyInt64{
		BaseProperty: &objectbox.BaseProperty{
			Id:     6,
			Entity: &ReadingBinding.Entity,
		},
	},
	ValueFloating: &objectbox.PropertyFloat64{
		BaseProperty: &objectbox.BaseProperty{
			Id:     7,
			Entity: &ReadingBinding.Entity,
		},
	},
	ValueInt32: &objectbox.PropertyInt32{
		BaseProperty: &objectbox.BaseProperty{
			Id:     8,
			Entity: &ReadingBinding.Entity,
		},
	},
	ValueFloating32: &objectbox.PropertyFloat32{
		BaseProperty: &objectbox.BaseProperty{
			Id:     9,
			Entity: &ReadingBinding.Entity,
		},
	},
}

Reading_ contains type-based Property helpers to facilitate some common operations such as Queries.

Functions

func LoadEmptyTestObjectBox

func LoadEmptyTestObjectBox() *objectbox.ObjectBox

func ObjectBoxModel

func ObjectBoxModel() *objectbox.Model

ObjectBoxModel declares and builds the model from all the entities in the package. It is usually used when setting-up ObjectBox as an argument to the Builder.Model() function.

Types

type Event

type Event struct {
	Id      uint64 `id`
	Uid     string `unique`
	Device  string
	Date    int64 `date`
	Picture []byte
}

func PutEvent

func PutEvent(ob *objectbox.ObjectBox, device string, date int64) *Event

func PutEvents

func PutEvents(ob *objectbox.ObjectBox, count int) []*Event

type EventBox

type EventBox struct {
	*objectbox.Box
}

Box provides CRUD access to Event objects

func BoxForEvent

func BoxForEvent(ob *objectbox.ObjectBox) *EventBox

BoxForEvent opens a box of Event objects

func (*EventBox) Get

func (box *EventBox) Get(id uint64) (*Event, error)

Get reads a single object.

Returns nil (and no error) in case the object with the given ID doesn't exist.

func (*EventBox) GetAll

func (box *EventBox) GetAll() ([]*Event, error)

Get reads all stored objects

func (*EventBox) Put added in v0.7.0

func (box *EventBox) Put(object *Event) (uint64, error)

Put synchronously inserts/updates a single object. In case the Id is not specified, it would be assigned automatically (auto-increment). When inserting, the Event.Id property on the passed object will be assigned the new ID as well.

func (*EventBox) PutAll added in v0.7.0

func (box *EventBox) PutAll(objects []*Event) ([]uint64, error)

PutAll inserts multiple objects in single transaction. In case Ids are not set on the objects, they would be assigned automatically (auto-increment).

Returns: IDs of the put objects (in the same order). When inserting, the Event.Id property on the objects in the slice will be assigned the new IDs as well.

Note: In case an error occurs during the transaction, some of the objects may already have the Event.Id assigned even though the transaction has been rolled back and the objects are not stored under those IDs.

Note: The slice may be empty or even nil; in both cases, an empty IDs slice and no error is returned.

func (*EventBox) PutAsync added in v0.7.0

func (box *EventBox) PutAsync(object *Event) (uint64, error)

PutAsync asynchronously inserts/updates a single object. When inserting, the Event.Id property on the passed object will be assigned the new ID as well.

It's executed on a separate internal thread for better performance.

There are two main use cases:

1) "Put & Forget:" you gain faster puts as you don't have to wait for the transaction to finish.

2) Many small transactions: if your write load is typically a lot of individual puts that happen in parallel, this will merge small transactions into bigger ones. This results in a significant gain in overall throughput.

In situations with (extremely) high async load, this method may be throttled (~1ms) or delayed (<1s). In the unlikely event that the object could not be enqueued after delaying, an error will be returned.

Note that this method does not give you hard durability guarantees like the synchronous Put provides. There is a small time window (typically 3 ms) in which the data may not have been committed durably yet.

func (*EventBox) Query added in v0.8.0

func (box *EventBox) Query(conditions ...objectbox.Condition) *EventQuery

Creates a query with the given conditions. Use the fields of the Event_ struct to create conditions. Keep the *EventQuery if you intend to execute the query multiple times. Note: this function panics if you try to create illegal queries; e.g. use properties of an alien type. This is typically a programming error. Use QueryOrError instead if you want the explicit error check.

func (*EventBox) QueryOrError added in v0.8.0

func (box *EventBox) QueryOrError(conditions ...objectbox.Condition) (*EventQuery, error)

Creates a query with the given conditions. Use the fields of the Event_ struct to create conditions. Keep the *EventQuery if you intend to execute the query multiple times.

func (*EventBox) Remove

func (box *EventBox) Remove(object *Event) (err error)

Remove deletes a single object

type EventQuery added in v0.8.0

type EventQuery struct {
	*objectbox.Query
}

Query provides a way to search stored objects

For example, you can find all Event which Id is either 42 or 47:

box.Query(Event_.Id.In(42, 47)).Find()

func (*EventQuery) Find added in v0.8.0

func (query *EventQuery) Find() ([]*Event, error)

Find returns all objects matching the query

func (*EventQuery) Limit added in v0.9.0

func (query *EventQuery) Limit(limit uint64) *EventQuery

Limit sets the number of elements to process by the query

func (*EventQuery) Offset added in v0.9.0

func (query *EventQuery) Offset(offset uint64) *EventQuery

Offset defines the index of the first object to process (how many objects to skip)

type Reading

type Reading struct {
	Id   uint64 `id`
	Date int64  `date`

	/// to-one relation
	EventId uint64 `link:"Event"`

	ValueName string

	/// Device sensor data value
	ValueString string

	/// Device sensor data value
	ValueInteger int64

	/// Device sensor data value
	ValueFloating float64

	/// Device sensor data value
	ValueInt32 int32

	/// Device sensor data value
	ValueFloating32 float32
}

func PutReading added in v0.7.0

func PutReading(ob *objectbox.ObjectBox, name string, ValueString string, ValueInteger int64, ValueFloating float64, ValueInt32 int32, ValueFloating32 float32) *Reading

func PutReadings added in v0.7.0

func PutReadings(ob *objectbox.ObjectBox, count int) []*Reading

type ReadingBox

type ReadingBox struct {
	*objectbox.Box
}

Box provides CRUD access to Reading objects

func BoxForReading

func BoxForReading(ob *objectbox.ObjectBox) *ReadingBox

BoxForReading opens a box of Reading objects

func (*ReadingBox) Get

func (box *ReadingBox) Get(id uint64) (*Reading, error)

Get reads a single object.

Returns nil (and no error) in case the object with the given ID doesn't exist.

func (*ReadingBox) GetAll

func (box *ReadingBox) GetAll() ([]*Reading, error)

Get reads all stored objects

func (*ReadingBox) Put added in v0.7.0

func (box *ReadingBox) Put(object *Reading) (uint64, error)

Put synchronously inserts/updates a single object. In case the Id is not specified, it would be assigned automatically (auto-increment). When inserting, the Reading.Id property on the passed object will be assigned the new ID as well.

func (*ReadingBox) PutAll added in v0.7.0

func (box *ReadingBox) PutAll(objects []*Reading) ([]uint64, error)

PutAll inserts multiple objects in single transaction. In case Ids are not set on the objects, they would be assigned automatically (auto-increment).

Returns: IDs of the put objects (in the same order). When inserting, the Reading.Id property on the objects in the slice will be assigned the new IDs as well.

Note: In case an error occurs during the transaction, some of the objects may already have the Reading.Id assigned even though the transaction has been rolled back and the objects are not stored under those IDs.

Note: The slice may be empty or even nil; in both cases, an empty IDs slice and no error is returned.

func (*ReadingBox) PutAsync added in v0.7.0

func (box *ReadingBox) PutAsync(object *Reading) (uint64, error)

PutAsync asynchronously inserts/updates a single object. When inserting, the Reading.Id property on the passed object will be assigned the new ID as well.

It's executed on a separate internal thread for better performance.

There are two main use cases:

1) "Put & Forget:" you gain faster puts as you don't have to wait for the transaction to finish.

2) Many small transactions: if your write load is typically a lot of individual puts that happen in parallel, this will merge small transactions into bigger ones. This results in a significant gain in overall throughput.

In situations with (extremely) high async load, this method may be throttled (~1ms) or delayed (<1s). In the unlikely event that the object could not be enqueued after delaying, an error will be returned.

Note that this method does not give you hard durability guarantees like the synchronous Put provides. There is a small time window (typically 3 ms) in which the data may not have been committed durably yet.

func (*ReadingBox) Query added in v0.8.0

func (box *ReadingBox) Query(conditions ...objectbox.Condition) *ReadingQuery

Creates a query with the given conditions. Use the fields of the Reading_ struct to create conditions. Keep the *ReadingQuery if you intend to execute the query multiple times. Note: this function panics if you try to create illegal queries; e.g. use properties of an alien type. This is typically a programming error. Use QueryOrError instead if you want the explicit error check.

func (*ReadingBox) QueryOrError added in v0.8.0

func (box *ReadingBox) QueryOrError(conditions ...objectbox.Condition) (*ReadingQuery, error)

Creates a query with the given conditions. Use the fields of the Reading_ struct to create conditions. Keep the *ReadingQuery if you intend to execute the query multiple times.

func (*ReadingBox) Remove

func (box *ReadingBox) Remove(object *Reading) (err error)

Remove deletes a single object

type ReadingQuery added in v0.8.0

type ReadingQuery struct {
	*objectbox.Query
}

Query provides a way to search stored objects

For example, you can find all Reading which Id is either 42 or 47:

box.Query(Reading_.Id.In(42, 47)).Find()

func (*ReadingQuery) Find added in v0.8.0

func (query *ReadingQuery) Find() ([]*Reading, error)

Find returns all objects matching the query

func (*ReadingQuery) Limit added in v0.9.0

func (query *ReadingQuery) Limit(limit uint64) *ReadingQuery

Limit sets the number of elements to process by the query

func (*ReadingQuery) Offset added in v0.9.0

func (query *ReadingQuery) Offset(offset uint64) *ReadingQuery

Offset defines the index of the first object to process (how many objects to skip)

Jump to

Keyboard shortcuts

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