Documentation ¶
Index ¶
- Variables
- func ObjectBoxModel() *objectbox.Model
- type Daily
- type DailyAsyncBox
- type DailyBox
- func (box *DailyBox) Async() *DailyAsyncBox
- func (box *DailyBox) Get(id uint64) (*Daily, error)
- func (box *DailyBox) GetAll() ([]*Daily, error)
- func (box *DailyBox) GetMany(ids ...uint64) ([]*Daily, error)
- func (box *DailyBox) GetManyExisting(ids ...uint64) ([]*Daily, error)
- func (box *DailyBox) Insert(object *Daily) (uint64, error)
- func (box *DailyBox) Put(object *Daily) (uint64, error)
- func (box *DailyBox) PutAsync(object *Daily) (uint64, error)
- func (box *DailyBox) PutMany(objects []*Daily) ([]uint64, error)
- func (box *DailyBox) Query(conditions ...objectbox.Condition) *DailyQuery
- func (box *DailyBox) QueryOrError(conditions ...objectbox.Condition) (*DailyQuery, error)
- func (box *DailyBox) Remove(object *Daily) error
- func (box *DailyBox) RemoveMany(objects ...*Daily) (uint64, error)
- func (box *DailyBox) Update(object *Daily) error
- type DailyQuery
- type Sample
- type SampleAsyncBox
- type SampleBox
- func (box *SampleBox) Async() *SampleAsyncBox
- func (box *SampleBox) Get(id uint64) (*Sample, error)
- func (box *SampleBox) GetAll() ([]*Sample, error)
- func (box *SampleBox) GetMany(ids ...uint64) ([]*Sample, error)
- func (box *SampleBox) GetManyExisting(ids ...uint64) ([]*Sample, error)
- func (box *SampleBox) Insert(object *Sample) (uint64, error)
- func (box *SampleBox) Put(object *Sample) (uint64, error)
- func (box *SampleBox) PutAsync(object *Sample) (uint64, error)
- func (box *SampleBox) PutMany(objects []*Sample) ([]uint64, error)
- func (box *SampleBox) Query(conditions ...objectbox.Condition) *SampleQuery
- func (box *SampleBox) QueryOrError(conditions ...objectbox.Condition) (*SampleQuery, error)
- func (box *SampleBox) Remove(object *Sample) error
- func (box *SampleBox) RemoveMany(objects ...*Sample) (uint64, error)
- func (box *SampleBox) Update(object *Sample) error
- type SampleQuery
Constants ¶
This section is empty.
Variables ¶
var DailyBinding = daily_EntityInfo{ Entity: objectbox.Entity{ Id: 2, }, Uid: 5404728982931877369, }
var Daily_ = struct { Id *objectbox.PropertyInt64 Date *objectbox.PropertyInt64 ProductionkWh *objectbox.PropertyFloat64 ConsumptionkWh *objectbox.PropertyFloat64 }{ Id: &objectbox.PropertyInt64{ BaseProperty: &objectbox.BaseProperty{ Id: 1, Entity: &DailyBinding.Entity, }, }, Date: &objectbox.PropertyInt64{ BaseProperty: &objectbox.BaseProperty{ Id: 2, Entity: &DailyBinding.Entity, }, }, ProductionkWh: &objectbox.PropertyFloat64{ BaseProperty: &objectbox.BaseProperty{ Id: 3, Entity: &DailyBinding.Entity, }, }, ConsumptionkWh: &objectbox.PropertyFloat64{ BaseProperty: &objectbox.BaseProperty{ Id: 4, Entity: &DailyBinding.Entity, }, }, }
Daily_ contains type-based Property helpers to facilitate some common operations such as Queries.
var SampleBinding = sample_EntityInfo{ Entity: objectbox.Entity{ Id: 1, }, Uid: 2567227502353939271, }
var Sample_ = struct { Id *objectbox.PropertyInt64 Date *objectbox.PropertyInt64 ProductionW *objectbox.PropertyFloat64 ConsumptionW *objectbox.PropertyFloat64 NetW *objectbox.PropertyFloat64 }{ Id: &objectbox.PropertyInt64{ BaseProperty: &objectbox.BaseProperty{ Id: 1, Entity: &SampleBinding.Entity, }, }, Date: &objectbox.PropertyInt64{ BaseProperty: &objectbox.BaseProperty{ Id: 2, Entity: &SampleBinding.Entity, }, }, ProductionW: &objectbox.PropertyFloat64{ BaseProperty: &objectbox.BaseProperty{ Id: 3, Entity: &SampleBinding.Entity, }, }, ConsumptionW: &objectbox.PropertyFloat64{ BaseProperty: &objectbox.BaseProperty{ Id: 4, Entity: &SampleBinding.Entity, }, }, NetW: &objectbox.PropertyFloat64{ BaseProperty: &objectbox.BaseProperty{ Id: 5, Entity: &SampleBinding.Entity, }, }, }
Sample_ 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 DailyAsyncBox ¶
DailyAsyncBox provides asynchronous operations on Daily 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 AsyncBoxForDaily ¶
func AsyncBoxForDaily(ob *objectbox.ObjectBox, timeoutMs uint64) *DailyAsyncBox
AsyncBoxForDaily 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 DailyBox::Async() which takes care of resource management and doesn't require closing.
func (*DailyAsyncBox) Insert ¶
func (asyncBox *DailyAsyncBox) Insert(object *Daily) (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 (*DailyAsyncBox) Put ¶
func (asyncBox *DailyAsyncBox) Put(object *Daily) (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 (*DailyAsyncBox) Remove ¶
func (asyncBox *DailyAsyncBox) Remove(object *Daily) error
Remove deletes a single object asynchronously.
func (*DailyAsyncBox) Update ¶
func (asyncBox *DailyAsyncBox) Update(object *Daily) error
Update a single object asynchronously. The object must already exists or the update fails silently (without an error returned).
type DailyBox ¶
Box provides CRUD access to Daily objects
func BoxForDaily ¶
BoxForDaily opens a box of Daily objects
func (*DailyBox) Async ¶
func (box *DailyBox) Async() *DailyAsyncBox
Async provides access to the default Async Box for asynchronous operations. See DailyAsyncBox for more information.
func (*DailyBox) Get ¶
Get reads a single object.
Returns nil (and no error) in case the object with the given ID doesn't exist.
func (*DailyBox) GetMany ¶
GetMany reads multiple objects at once. If any of the objects doesn't exist, its position in the return slice is nil
func (*DailyBox) GetManyExisting ¶
GetManyExisting reads multiple objects at once, skipping those that do not exist.
func (*DailyBox) Insert ¶
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 Daily.Id property on the passed object will be assigned the new ID as well.
func (*DailyBox) Put ¶
Put synchronously inserts/updates a single object. In case the Id is not specified, it would be assigned automatically (auto-increment). When inserting, the Daily.Id property on the passed object will be assigned the new ID as well.
func (*DailyBox) PutAsync ¶
PutAsync asynchronously inserts/updates a single object. Deprecated: use box.Async().Put() instead
func (*DailyBox) PutMany ¶
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 Daily.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 Daily.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 (*DailyBox) Query ¶
func (box *DailyBox) Query(conditions ...objectbox.Condition) *DailyQuery
Creates a query with the given conditions. Use the fields of the Daily_ struct to create conditions. Keep the *DailyQuery 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 (*DailyBox) QueryOrError ¶
func (box *DailyBox) QueryOrError(conditions ...objectbox.Condition) (*DailyQuery, error)
Creates a query with the given conditions. Use the fields of the Daily_ struct to create conditions. Keep the *DailyQuery if you intend to execute the query multiple times.
func (*DailyBox) RemoveMany ¶
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 DailyQuery ¶
Query provides a way to search stored objects
For example, you can find all Daily which Id is either 42 or 47:
box.Query(Daily_.Id.In(42, 47)).Find()
func (*DailyQuery) Find ¶
func (query *DailyQuery) Find() ([]*Daily, error)
Find returns all objects matching the query
func (*DailyQuery) Limit ¶
func (query *DailyQuery) Limit(limit uint64) *DailyQuery
Limit sets the number of elements to process by the query
func (*DailyQuery) Offset ¶
func (query *DailyQuery) Offset(offset uint64) *DailyQuery
Offset defines the index of the first object to process (how many objects to skip)
type Sample ¶
type Sample struct { Id int64 `objectbox:"id"` Date int64 ProductionW float64 ConsumptionW float64 NetW float64 }
next schema change convert Date to time.Time `objectbox:"date"`
type SampleAsyncBox ¶
SampleAsyncBox provides asynchronous operations on Sample 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 AsyncBoxForSample ¶
func AsyncBoxForSample(ob *objectbox.ObjectBox, timeoutMs uint64) *SampleAsyncBox
AsyncBoxForSample 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 SampleBox::Async() which takes care of resource management and doesn't require closing.
func (*SampleAsyncBox) Insert ¶
func (asyncBox *SampleAsyncBox) Insert(object *Sample) (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 (*SampleAsyncBox) Put ¶
func (asyncBox *SampleAsyncBox) Put(object *Sample) (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 (*SampleAsyncBox) Remove ¶
func (asyncBox *SampleAsyncBox) Remove(object *Sample) error
Remove deletes a single object asynchronously.
func (*SampleAsyncBox) Update ¶
func (asyncBox *SampleAsyncBox) Update(object *Sample) error
Update a single object asynchronously. The object must already exists or the update fails silently (without an error returned).
type SampleBox ¶
Box provides CRUD access to Sample objects
func BoxForSample ¶
BoxForSample opens a box of Sample objects
func (*SampleBox) Async ¶
func (box *SampleBox) Async() *SampleAsyncBox
Async provides access to the default Async Box for asynchronous operations. See SampleAsyncBox for more information.
func (*SampleBox) Get ¶
Get reads a single object.
Returns nil (and no error) in case the object with the given ID doesn't exist.
func (*SampleBox) GetMany ¶
GetMany reads multiple objects at once. If any of the objects doesn't exist, its position in the return slice is nil
func (*SampleBox) GetManyExisting ¶
GetManyExisting reads multiple objects at once, skipping those that do not exist.
func (*SampleBox) Insert ¶
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 Sample.Id property on the passed object will be assigned the new ID as well.
func (*SampleBox) Put ¶
Put synchronously inserts/updates a single object. In case the Id is not specified, it would be assigned automatically (auto-increment). When inserting, the Sample.Id property on the passed object will be assigned the new ID as well.
func (*SampleBox) PutAsync ¶
PutAsync asynchronously inserts/updates a single object. Deprecated: use box.Async().Put() instead
func (*SampleBox) PutMany ¶
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 Sample.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 Sample.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 (*SampleBox) Query ¶
func (box *SampleBox) Query(conditions ...objectbox.Condition) *SampleQuery
Creates a query with the given conditions. Use the fields of the Sample_ struct to create conditions. Keep the *SampleQuery 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 (*SampleBox) QueryOrError ¶
func (box *SampleBox) QueryOrError(conditions ...objectbox.Condition) (*SampleQuery, error)
Creates a query with the given conditions. Use the fields of the Sample_ struct to create conditions. Keep the *SampleQuery if you intend to execute the query multiple times.
func (*SampleBox) RemoveMany ¶
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 SampleQuery ¶
Query provides a way to search stored objects
For example, you can find all Sample which Id is either 42 or 47:
box.Query(Sample_.Id.In(42, 47)).Find()
func (*SampleQuery) Find ¶
func (query *SampleQuery) Find() ([]*Sample, error)
Find returns all objects matching the query
func (*SampleQuery) Limit ¶
func (query *SampleQuery) Limit(limit uint64) *SampleQuery
Limit sets the number of elements to process by the query
func (*SampleQuery) Offset ¶
func (query *SampleQuery) Offset(offset uint64) *SampleQuery
Offset defines the index of the first object to process (how many objects to skip)