objectbox-go: github.com/objectbox/objectbox-go/test/model/iot Index | Files

package iot

import "github.com/objectbox/objectbox-go/test/model/iot"

Index

Package Files

helper.go model.go model.obx.go objectbox-model.go

Variables

var EventBinding = event_EntityInfo{
    Entity: objectbox.Entity{
        Id: 1,
    },
    Uid: 1468539308767086854,
}
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.

var ReadingBinding = reading_EntityInfo{
    Entity: objectbox.Entity{
        Id: 2,
    },
    Uid: 5284076134434938613,
}
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.

func LoadEmptyTestObjectBox Uses

func LoadEmptyTestObjectBox() *objectbox.ObjectBox

func ObjectBoxModel Uses

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.

type Event Uses

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

func PutEvent Uses

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

func PutEvents Uses

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

type EventBox Uses

type EventBox struct {
    *objectbox.Box
}

Box provides CRUD access to Event objects

func BoxForEvent Uses

func BoxForEvent(ob *objectbox.ObjectBox) *EventBox

BoxForEvent opens a box of Event objects

func (*EventBox) Get Uses

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 Uses

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

GetAll reads all stored objects

func (*EventBox) GetMany Uses

func (box *EventBox) GetMany(ids ...uint64) ([]*Event, error)

GetMany reads multiple objects at once. If any of the objects doesn't exist, its position in the return slice is nil

func (*EventBox) Put Uses

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) PutAsync Uses

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) PutMany Uses

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

PutMany 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) Query Uses

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 Uses

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 Uses

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

Remove deletes a single object

func (*EventBox) RemoveMany Uses

func (box *EventBox) RemoveMany(objects ...*Event) (uint64, error)

RemoveMany deletes multiple objects at once. Returns the number of deleted object or error on failure. Note that this method will not fail if an object is not found (e.g. already removed). In case you need to strictly check whether all of the objects exist before removing them, you can execute multiple box.Contains() and box.Remove() inside a single write transaction.

type EventQuery Uses

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 Uses

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

Find returns all objects matching the query

func (*EventQuery) Limit Uses

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

Limit sets the number of elements to process by the query

func (*EventQuery) Offset Uses

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

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

type Reading Uses

type Reading struct {
    Id   uint64 `objectbox:"id"`
    Date int64  `objectbox:"date"`

    /// to-one relation
    EventId uint64 `objectbox:"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 Uses

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

func PutReadings Uses

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

type ReadingBox Uses

type ReadingBox struct {
    *objectbox.Box
}

Box provides CRUD access to Reading objects

func BoxForReading Uses

func BoxForReading(ob *objectbox.ObjectBox) *ReadingBox

BoxForReading opens a box of Reading objects

func (*ReadingBox) Get Uses

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 Uses

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

GetAll reads all stored objects

func (*ReadingBox) GetMany Uses

func (box *ReadingBox) GetMany(ids ...uint64) ([]*Reading, error)

GetMany reads multiple objects at once. If any of the objects doesn't exist, its position in the return slice is nil

func (*ReadingBox) Put Uses

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) PutAsync Uses

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) PutMany Uses

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

PutMany 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) Query Uses

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 Uses

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 Uses

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

Remove deletes a single object

func (*ReadingBox) RemoveMany Uses

func (box *ReadingBox) RemoveMany(objects ...*Reading) (uint64, error)

RemoveMany deletes multiple objects at once. Returns the number of deleted object or error on failure. Note that this method will not fail if an object is not found (e.g. already removed). In case you need to strictly check whether all of the objects exist before removing them, you can execute multiple box.Contains() and box.Remove() inside a single write transaction.

type ReadingQuery Uses

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 Uses

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

Find returns all objects matching the query

func (*ReadingQuery) Limit Uses

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

Limit sets the number of elements to process by the query

func (*ReadingQuery) Offset Uses

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

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

Package iot imports 6 packages (graph). Updated 2019-07-19. Refresh now. Tools for package owners.