Documentation
¶
Index ¶
- Variables
- func ObjectBoxModel() *objectbox.Model
- type Task
- type TaskBox
- func (box *TaskBox) Get(id uint64) (*Task, error)
- func (box *TaskBox) GetAll() ([]*Task, error)
- func (box *TaskBox) Put(object *Task) (uint64, error)
- func (box *TaskBox) PutAll(objects []*Task) ([]uint64, error)
- func (box *TaskBox) PutAsync(object *Task) (uint64, error)
- func (box *TaskBox) Query(conditions ...objectbox.Condition) *TaskQuery
- func (box *TaskBox) QueryOrError(conditions ...objectbox.Condition) (*TaskQuery, error)
- func (box *TaskBox) Remove(object *Task) (err error)
- type TaskQuery
Constants ¶
This section is empty.
Variables ¶
var TaskBinding = task_EntityInfo{ Entity: objectbox.Entity{ Id: 1, }, Uid: 1306759095002958910, }
var Task_ = struct { Id *objectbox.PropertyUint64 Text *objectbox.PropertyString DateCreated *objectbox.PropertyInt64 DateFinished *objectbox.PropertyInt64 }{ Id: &objectbox.PropertyUint64{ BaseProperty: &objectbox.BaseProperty{ Id: 1, Entity: &TaskBinding.Entity, }, }, Text: &objectbox.PropertyString{ BaseProperty: &objectbox.BaseProperty{ Id: 2, Entity: &TaskBinding.Entity, }, }, DateCreated: &objectbox.PropertyInt64{ BaseProperty: &objectbox.BaseProperty{ Id: 3, Entity: &TaskBinding.Entity, }, }, DateFinished: &objectbox.PropertyInt64{ BaseProperty: &objectbox.BaseProperty{ Id: 4, Entity: &TaskBinding.Entity, }, }, }
Task_ 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 TaskBox ¶
Box provides CRUD access to Task objects
func BoxForTask ¶
BoxForTask opens a box of Task objects
func (*TaskBox) Get ¶
Get reads a single object.
Returns nil (and no error) in case the object with the given ID doesn't exist.
func (*TaskBox) 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 Task.Id property on the passed object will be assigned the new ID as well.
func (*TaskBox) PutAll ¶ added in v0.7.0
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 Task.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 Task.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 (*TaskBox) PutAsync ¶ added in v0.7.0
PutAsync asynchronously inserts/updates a single object. When inserting, the Task.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 (*TaskBox) Query ¶ added in v0.8.0
Creates a query with the given conditions. Use the fields of the Task_ struct to create conditions. Keep the *TaskQuery 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 (*TaskBox) QueryOrError ¶ added in v0.8.0
Creates a query with the given conditions. Use the fields of the Task_ struct to create conditions. Keep the *TaskQuery if you intend to execute the query multiple times.
type TaskQuery ¶ added in v0.8.0
Query provides a way to search stored objects
For example, you can find all Task which Id is either 42 or 47:
box.Query(Task_.Id.In(42, 47)).Find()