model

package
v0.0.0-...-6106dd3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 4, 2019 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TableBinding = table_EntityInfo{
	Id:  1,
	Uid: 8927767662064279822,
}
View Source
var Table_ = struct {
	Id   *objectbox.PropertyUint64
	Name *objectbox.PropertyString
	data *objectbox.PropertyByteVector
}{
	Id: &objectbox.PropertyUint64{
		Property: &objectbox.Property{
			Id: 1,
		},
	},
	Name: &objectbox.PropertyString{
		Property: &objectbox.Property{
			Id: 2,
		},
	},
	// contains filtered or unexported fields
}

Table_ contains type-based Property helpers to facilitate some common operations such as Queries.

Functions

func CreateTableCache

func CreateTableCache(name string, rc io.Reader) (Id uint64, err error)

func GetTableCache

func GetTableCache(id uint64) (io.ReadCloser, error)

func ObjectBoxModel

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.

Types

type Table

type Table struct {
	Id   uint64
	Name string
	// contains filtered or unexported fields
}

type TableBox

type TableBox struct {
	*objectbox.Box
}

Box provides CRUD access to Table objects

func BoxForTable

func BoxForTable(ob *objectbox.ObjectBox) *TableBox

BoxForTable opens a box of Table objects

func (*TableBox) Get

func (box *TableBox) Get(id uint64) (*Table, error)

Get reads a single object.

Returns nil (and no error) in case the object with the given ID doesn't exist.

func (*TableBox) GetAll

func (box *TableBox) GetAll() ([]*Table, error)

Get reads all stored objects

func (*TableBox) Put

func (box *TableBox) Put(object *Table) (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 Table.Id property on the passed object will be assigned the new ID as well.

func (*TableBox) PutAll

func (box *TableBox) PutAll(objects []*Table) ([]uint64, error)

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 Table.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 Table.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 (*TableBox) PutAsync

func (box *TableBox) PutAsync(object *Table) (uint64, error)

PutAsync asynchronously inserts/updates a single object. When inserting, the Table.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 (*TableBox) Query

func (box *TableBox) Query(conditions ...objectbox.Condition) *TableQuery

Creates a query with the given conditions. Use the fields of the Table_ struct to create conditions. Keep the *TableQuery 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 (*TableBox) QueryOrError

func (box *TableBox) QueryOrError(conditions ...objectbox.Condition) (*TableQuery, error)

Creates a query with the given conditions. Use the fields of the Table_ struct to create conditions. Keep the *TableQuery if you intend to execute the query multiple times.

func (*TableBox) Remove

func (box *TableBox) Remove(object *Table) (err error)

Remove deletes a single object

type TableQuery

type TableQuery struct {
	*objectbox.Query
}

Query provides a way to search stored objects

For example, you can find all Table which Id is either 42 or 47:

box.Query(Table_.Id.In(42, 47)).Find()

func (*TableQuery) Find

func (query *TableQuery) Find() ([]*Table, error)

Find returns all objects matching the query

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL