Documentation
¶
Index ¶
- Variables
- func ObjectBoxModel() *objectbox.Model
- type Entity
- type EntityBox
- func (box *EntityBox) Get(id uint64) (*Entity, error)
- func (box *EntityBox) GetAll() ([]*Entity, error)
- func (box *EntityBox) Put(object *Entity) (uint64, error)
- func (box *EntityBox) PutAll(objects []*Entity) ([]uint64, error)
- func (box *EntityBox) PutAsync(object *Entity) (uint64, error)
- func (box *EntityBox) Query(conditions ...objectbox.Condition) *EntityQuery
- func (box *EntityBox) QueryOrError(conditions ...objectbox.Condition) (*EntityQuery, error)
- func (box *EntityBox) Remove(object *Entity) (err error)
- type EntityQuery
- type TestEnv
Constants ¶
This section is empty.
Variables ¶
var EntityBinding = entity_EntityInfo{
Id: 1,
Uid: 3022148985475790732,
}
var Entity_ = struct { Id *objectbox.PropertyUint64 Int *objectbox.PropertyInt Int8 *objectbox.PropertyInt8 Int16 *objectbox.PropertyInt16 Int32 *objectbox.PropertyInt32 Int64 *objectbox.PropertyInt64 Uint *objectbox.PropertyUint Uint8 *objectbox.PropertyUint8 Uint16 *objectbox.PropertyUint16 Uint32 *objectbox.PropertyUint32 Uint64 *objectbox.PropertyUint64 Bool *objectbox.PropertyBool String *objectbox.PropertyString Byte *objectbox.PropertyByte ByteVector *objectbox.PropertyByteVector Rune *objectbox.PropertyRune Float32 *objectbox.PropertyFloat32 Float64 *objectbox.PropertyFloat64 Date *objectbox.PropertyInt64 }{ Id: &objectbox.PropertyUint64{ Property: &objectbox.Property{ Id: 1, }, }, Int: &objectbox.PropertyInt{ Property: &objectbox.Property{ Id: 2, }, }, Int8: &objectbox.PropertyInt8{ Property: &objectbox.Property{ Id: 3, }, }, Int16: &objectbox.PropertyInt16{ Property: &objectbox.Property{ Id: 4, }, }, Int32: &objectbox.PropertyInt32{ Property: &objectbox.Property{ Id: 5, }, }, Int64: &objectbox.PropertyInt64{ Property: &objectbox.Property{ Id: 6, }, }, Uint: &objectbox.PropertyUint{ Property: &objectbox.Property{ Id: 7, }, }, Uint8: &objectbox.PropertyUint8{ Property: &objectbox.Property{ Id: 8, }, }, Uint16: &objectbox.PropertyUint16{ Property: &objectbox.Property{ Id: 9, }, }, Uint32: &objectbox.PropertyUint32{ Property: &objectbox.Property{ Id: 10, }, }, Uint64: &objectbox.PropertyUint64{ Property: &objectbox.Property{ Id: 11, }, }, Bool: &objectbox.PropertyBool{ Property: &objectbox.Property{ Id: 12, }, }, String: &objectbox.PropertyString{ Property: &objectbox.Property{ Id: 13, }, }, Byte: &objectbox.PropertyByte{ Property: &objectbox.Property{ Id: 14, }, }, ByteVector: &objectbox.PropertyByteVector{ Property: &objectbox.Property{ Id: 15, }, }, Rune: &objectbox.PropertyRune{ Property: &objectbox.Property{ Id: 16, }, }, Float32: &objectbox.PropertyFloat32{ Property: &objectbox.Property{ Id: 17, }, }, Float64: &objectbox.PropertyFloat64{ Property: &objectbox.Property{ Id: 18, }, }, Date: &objectbox.PropertyInt64{ Property: &objectbox.Property{ Id: 19, }, }, }
Entity_ 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 Entity ¶
type Entity struct {
Id uint64
Int int
Int8 int8
Int16 int16
Int32 int32
Int64 int64
Uint uint
Uint8 uint8
Uint16 uint16
Uint32 uint32
Uint64 uint64
Bool bool
String string
Byte byte
ByteVector []byte
Rune rune
Float32 float32
Float64 float64
Date int64 `date`
}
Tests all available GO & ObjectBox types TODO rename; e.g. TestEntity
type EntityBox ¶
Box provides CRUD access to Entity objects
func BoxForEntity ¶
BoxForEntity opens a box of Entity objects
func (*EntityBox) Get ¶
Get reads a single object.
Returns nil (and no error) in case the object with the given ID doesn't exist.
func (*EntityBox) 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 Entity.Id property on the passed object will be assigned the new ID as well.
func (*EntityBox) PutAll ¶
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 Entity.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 Entity.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 (*EntityBox) PutAsync ¶
PutAsync asynchronously inserts/updates a single object. When inserting, the Entity.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 (*EntityBox) Query ¶
func (box *EntityBox) Query(conditions ...objectbox.Condition) *EntityQuery
Creates a query with the given conditions. Use the fields of the Entity_ struct to create conditions. Keep the *EntityQuery 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 (*EntityBox) QueryOrError ¶
func (box *EntityBox) QueryOrError(conditions ...objectbox.Condition) (*EntityQuery, error)
Creates a query with the given conditions. Use the fields of the Entity_ struct to create conditions. Keep the *EntityQuery if you intend to execute the query multiple times.
type EntityQuery ¶
Query provides a way to search stored objects
For example, you can find all Entity which Id is either 42 or 47:
box.Query(Entity_.Id.In(42, 47)).Find()
func (*EntityQuery) Find ¶
func (query *EntityQuery) Find() ([]*Entity, error)
Find returns all objects matching the query