Documentation ¶
Index ¶
- Variables
- func ObjectBoxModel() *objectbox.Model
- type Event
- type EventAsyncBox
- type EventBox
- func (box *EventBox) Async() *EventAsyncBox
- func (box *EventBox) Get(id uint64) (*Event, error)
- func (box *EventBox) GetAll() ([]*Event, error)
- func (box *EventBox) GetMany(ids ...uint64) ([]*Event, error)
- func (box *EventBox) GetManyExisting(ids ...uint64) ([]*Event, error)
- func (box *EventBox) Insert(object *Event) (uint64, error)
- func (box *EventBox) Put(object *Event) (uint64, error)
- func (box *EventBox) PutAsync(object *Event) (uint64, error)
- func (box *EventBox) PutMany(objects []*Event) ([]uint64, error)
- func (box *EventBox) Query(conditions ...objectbox.Condition) *EventQuery
- func (box *EventBox) QueryOrError(conditions ...objectbox.Condition) (*EventQuery, error)
- func (box *EventBox) Remove(object *Event) error
- func (box *EventBox) RemoveMany(objects ...*Event) (uint64, error)
- func (box *EventBox) Update(object *Event) error
- type EventQuery
- type Reading
- type ReadingAsyncBox
- type ReadingBox
- func (box *ReadingBox) Async() *ReadingAsyncBox
- func (box *ReadingBox) Get(id uint64) (*Reading, error)
- func (box *ReadingBox) GetAll() ([]*Reading, error)
- func (box *ReadingBox) GetMany(ids ...uint64) ([]*Reading, error)
- func (box *ReadingBox) GetManyExisting(ids ...uint64) ([]*Reading, error)
- func (box *ReadingBox) Insert(object *Reading) (uint64, error)
- func (box *ReadingBox) Put(object *Reading) (uint64, error)
- func (box *ReadingBox) PutAsync(object *Reading) (uint64, error)
- func (box *ReadingBox) PutMany(objects []*Reading) ([]uint64, error)
- func (box *ReadingBox) Query(conditions ...objectbox.Condition) *ReadingQuery
- func (box *ReadingBox) QueryOrError(conditions ...objectbox.Condition) (*ReadingQuery, error)
- func (box *ReadingBox) Remove(object *Reading) error
- func (box *ReadingBox) RemoveMany(objects ...*Reading) (uint64, error)
- func (box *ReadingBox) Update(object *Reading) error
- type ReadingQuery
- type TestEnv
Constants ¶
This section is empty.
Variables ¶
var EventBinding = event_EntityInfo{ Entity: objectbox.Entity{ Id: 1, }, Uid: 1468539308767086854, }
var Event_ = struct { Id *objectbox.PropertyUint64 Device *objectbox.PropertyString Date *objectbox.PropertyInt64 Uid *objectbox.PropertyString Picture *objectbox.PropertyByteVector }{ Id: &objectbox.PropertyUint64{ BaseProperty: &objectbox.BaseProperty{ Id: 1, 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, }, }, Uid: &objectbox.PropertyString{ BaseProperty: &objectbox.BaseProperty{ Id: 4, 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.
Functions ¶
func ObjectBoxModel ¶
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 `objectbox:"id"` Uid string `objectbox:"unique"` Device string Date int64 `objectbox:"date"` Picture []byte }
Event model
type EventAsyncBox ¶ added in v1.1.0
EventAsyncBox provides asynchronous operations on Event objects.
Asynchronous operations are executed on a separate internal thread for better performance.
There are two main use cases:
1) "execute & forget:" you gain faster put/remove operations 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, an async method may be throttled (~1ms) or delayed up to 1 second. In the unlikely event that the object could still not be enqueued (full queue), an error will be returned.
Note that async methods do not give you hard durability guarantees like the synchronous Box provides. There is a small time window in which the data may not have been committed durably yet.
func AsyncBoxForEvent ¶ added in v1.1.0
func AsyncBoxForEvent(ob *objectbox.ObjectBox, timeoutMs uint64) *EventAsyncBox
AsyncBoxForEvent creates a new async box with the given operation timeout in case an async queue is full. The returned struct must be freed explicitly using the Close() method. It's usually preferable to use EventBox::Async() which takes care of resource management and doesn't require closing.
func (*EventAsyncBox) Insert ¶ added in v1.1.0
func (asyncBox *EventAsyncBox) Insert(object *Event) (id uint64, err error)
Insert a single object asynchronously. The Id property on the passed object will be assigned the new ID the entity would hold if the insert is ultimately successful. The newly assigned ID may not become valid if the insert fails. Fails silently if an object with the same ID already exists (this error is not returned).
func (*EventAsyncBox) Put ¶ added in v1.1.0
func (asyncBox *EventAsyncBox) Put(object *Event) (uint64, error)
Put inserts/updates a single object asynchronously. When inserting a new object, the Id property on the passed object will be assigned the new ID the entity would hold if the insert is ultimately successful. The newly assigned ID may not become valid if the insert fails.
func (*EventAsyncBox) Remove ¶ added in v1.1.0
func (asyncBox *EventAsyncBox) Remove(object *Event) error
Remove deletes a single object asynchronously.
func (*EventAsyncBox) Update ¶ added in v1.1.0
func (asyncBox *EventAsyncBox) Update(object *Event) error
Update a single object asynchronously. The object must already exists or the update fails silently (without an error returned).
type EventBox ¶
Box provides CRUD access to Event objects
func BoxForEvent ¶
BoxForEvent opens a box of Event objects
func (*EventBox) Async ¶ added in v1.1.0
func (box *EventBox) Async() *EventAsyncBox
Async provides access to the default Async Box for asynchronous operations. See EventAsyncBox for more information.
func (*EventBox) Get ¶
Get reads a single object.
Returns nil (and no error) in case the object with the given ID doesn't exist.
func (*EventBox) GetMany ¶ added in v1.0.0
GetMany reads multiple objects at once. If any of the objects doesn't exist, its position in the return slice is nil
func (*EventBox) GetManyExisting ¶ added in v1.1.0
GetManyExisting reads multiple objects at once, skipping those that do not exist.
func (*EventBox) Insert ¶ added in v1.1.0
Insert synchronously inserts a single object. As opposed to Put, Insert will fail if given an ID that already exists. 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) Put ¶ added in v0.7.0
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 ¶ added in v0.7.0
PutAsync asynchronously inserts/updates a single object. Deprecated: use box.Async().Put() instead
func (*EventBox) PutMany ¶ added in v1.0.0
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 ¶ 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) RemoveMany ¶ added in v1.0.0
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 ¶ added in v0.8.0
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 `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 }
Reading model
type ReadingAsyncBox ¶ added in v1.1.0
ReadingAsyncBox provides asynchronous operations on Reading objects.
Asynchronous operations are executed on a separate internal thread for better performance.
There are two main use cases:
1) "execute & forget:" you gain faster put/remove operations 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, an async method may be throttled (~1ms) or delayed up to 1 second. In the unlikely event that the object could still not be enqueued (full queue), an error will be returned.
Note that async methods do not give you hard durability guarantees like the synchronous Box provides. There is a small time window in which the data may not have been committed durably yet.
func AsyncBoxForReading ¶ added in v1.1.0
func AsyncBoxForReading(ob *objectbox.ObjectBox, timeoutMs uint64) *ReadingAsyncBox
AsyncBoxForReading creates a new async box with the given operation timeout in case an async queue is full. The returned struct must be freed explicitly using the Close() method. It's usually preferable to use ReadingBox::Async() which takes care of resource management and doesn't require closing.
func (*ReadingAsyncBox) Insert ¶ added in v1.1.0
func (asyncBox *ReadingAsyncBox) Insert(object *Reading) (id uint64, err error)
Insert a single object asynchronously. The Id property on the passed object will be assigned the new ID the entity would hold if the insert is ultimately successful. The newly assigned ID may not become valid if the insert fails. Fails silently if an object with the same ID already exists (this error is not returned).
func (*ReadingAsyncBox) Put ¶ added in v1.1.0
func (asyncBox *ReadingAsyncBox) Put(object *Reading) (uint64, error)
Put inserts/updates a single object asynchronously. When inserting a new object, the Id property on the passed object will be assigned the new ID the entity would hold if the insert is ultimately successful. The newly assigned ID may not become valid if the insert fails.
func (*ReadingAsyncBox) Remove ¶ added in v1.1.0
func (asyncBox *ReadingAsyncBox) Remove(object *Reading) error
Remove deletes a single object asynchronously.
func (*ReadingAsyncBox) Update ¶ added in v1.1.0
func (asyncBox *ReadingAsyncBox) Update(object *Reading) error
Update a single object asynchronously. The object must already exists or the update fails silently (without an error returned).
type ReadingBox ¶
Box provides CRUD access to Reading objects
func BoxForReading ¶
func BoxForReading(ob *objectbox.ObjectBox) *ReadingBox
BoxForReading opens a box of Reading objects
func (*ReadingBox) Async ¶ added in v1.1.0
func (box *ReadingBox) Async() *ReadingAsyncBox
Async provides access to the default Async Box for asynchronous operations. See ReadingAsyncBox for more information.
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)
GetAll reads all stored objects
func (*ReadingBox) GetMany ¶ added in v1.0.0
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) GetManyExisting ¶ added in v1.1.0
func (box *ReadingBox) GetManyExisting(ids ...uint64) ([]*Reading, error)
GetManyExisting reads multiple objects at once, skipping those that do not exist.
func (*ReadingBox) Insert ¶ added in v1.1.0
func (box *ReadingBox) Insert(object *Reading) (uint64, error)
Insert synchronously inserts a single object. As opposed to Put, Insert will fail if given an ID that already exists. 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) 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) PutAsync ¶ added in v0.7.0
func (box *ReadingBox) PutAsync(object *Reading) (uint64, error)
PutAsync asynchronously inserts/updates a single object. Deprecated: use box.Async().Put() instead
func (*ReadingBox) PutMany ¶ added in v1.0.0
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 ¶ 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) error
Remove deletes a single object
func (*ReadingBox) RemoveMany ¶ added in v1.0.0
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.
func (*ReadingBox) Update ¶ added in v1.1.0
func (box *ReadingBox) Update(object *Reading) error
Update synchronously updates a single object. As opposed to Put, Update will fail if an object with the same ID is not found in the database.
type ReadingQuery ¶ added in v0.8.0
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)
type TestEnv ¶ added in v1.1.1
func NewTestEnv ¶ added in v1.1.1
func NewTestEnv() *TestEnv
NewTestEnv creates an empty ObjectBox instance