func (box *Box) Contains(id uint64) (bool, error) {
	var cResult C.bool
	if err := cCall(func() C.obx_err { return C.obx_box_contains(box.cBox, C.obx_id(id), &cResult) }); err != nil {
		return false, err
	}
	return bool(cResult), nil
}
Contains checks whether an object with the given ID is stored.
package objectbox
import "C"
import (
	"errors"
	"fmt"
	"reflect"
	"runtime"
	"unsafe"
	"github.com/google/flatbuffers/go"
)
type Box struct {
	ObjectBox *ObjectBox
	entity    *entity
	cBox      *C.OBX_box
	async     *AsyncBox
}
const defaultSliceCapacity = 16
func newBox(ob *ObjectBox, entityId TypeId) (*Box, error) {
	var box = &Box{
		ObjectBox: ob,
		entity:    ob.getEntityById(entityId),
	}
	if err := cCallBool(func() bool {
		box.cBox = C.obx_box(ob.store, C.obx_schema_id(entityId))
		return box.cBox != nil
	}); err != nil {
		return nil, err
	}
	box.async = &AsyncBox{
		box:    box,
		cOwned: false,
	}
	if err := cCallBool(func() bool {
		box.async.cAsync = C.obx_async(box.cBox)
		return box.async.cAsync != nil
	}); err != nil {
		return nil, err
	}
	return box, nil
}
func (box *Box) Async() *AsyncBox {
	return box.async
}
func (box *Box) Query(conditions ...Condition) *Query {
	query, err := box.QueryOrError(conditions...)
	if err != nil {
		panic(fmt.Sprintf("Could not create query - please check your query conditions: %s", err))
	}
	return query
}
func (box *Box) QueryOrError(conditions ...Condition) (query *Query, err error) {
	builder := newQueryBuilder(box.ObjectBox, box.entity.id)
	defer func() {
		err2 := builder.Close()
		if err == nil && err2 != nil {
			err = err2
			query = nil
		}
	}()
	if err = builder.applyConditions(conditions); err != nil {
		return nil, err
	}
	query, err = builder.Build(box)
	return  
}
func (box *Box) idForPut(idCandidate uint64) (id uint64, err error) {
	id = uint64(C.obx_box_id_for_put(box.cBox, C.obx_id(idCandidate)))
	if id == 0 {  
		runtime.LockOSThread()
		id = uint64(C.obx_box_id_for_put(box.cBox, C.obx_id(idCandidate)))
		if id == 0 {
			err = createError()
		}
		runtime.UnlockOSThread()
	}
	return
}
func (box *Box) idsForPut(count int) (firstId uint64, err error) {
	if count == 0 {
		return 0, nil
	}
	var cFirstID C.obx_id
	if err := cCall(func() C.obx_err {
		return C.obx_box_ids_for_put(box.cBox, C.uint64_t(count), &cFirstID)
	}); err != nil {
		return 0, err
	}
	return uint64(cFirstID), nil
}
func (box *Box) put(object interface{}, alreadyInTx bool, putMode C.OBXPutMode) (id uint64, err error) {
	idFromObject, err := box.entity.binding.GetId(object)
	if err != nil {
		return 0, err
	}
	if putMode == cPutModeUpdate {
		id = idFromObject
		if idFromObject == 0 {
			return 0, errors.New("cannot update an object with ID 0 - if it's a new object use Put or Insert instead")
		}
	} else {
		id, err = box.idForPut(idFromObject)
		if err != nil {
			return 0, err
		}
	}
	if box.entity.hasRelations && !alreadyInTx {
		err = box.ObjectBox.RunInWriteTx(func() error {
			return box.putOne(id, object, putMode)
		})
	} else {
		err = box.putOne(id, object, putMode)
	}
	if err == nil && idFromObject != id {
		err = box.entity.binding.SetId(object, id)
	}
	if err != nil {
		id = 0
	}
	return id, err
}
func (box *Box) putOne(id uint64, object interface{}, putMode C.OBXPutMode) error {
	if box.entity.hasRelations {  
		if err := box.entity.binding.PutRelated(box.ObjectBox, object, id); err != nil {
			return err
		}
	}
	return box.withObjectBytes(object, id, func(bytes []byte) error {
		return cCall(func() C.obx_err {
			return C.obx_box_put5(box.cBox, C.obx_id(id), unsafe.Pointer(&bytes[0]), C.size_t(len(bytes)), putMode)
		})
	})
}
func (box *Box) withObjectBytes(object interface{}, id uint64, fn func([]byte) error) error {
	var fbb = fbbPool.Get().(*flatbuffers.Builder)
	err := box.entity.binding.Flatten(object, fbb, id)
	if err == nil {
		fbb.Finish(fbb.EndObject())
		err = fn(fbb.FinishedBytes())
	}
	if cap(fbb.Bytes) < 1024*1024 {
		fbb.Reset()
		fbbPool.Put(fbb)
	}
	return err
}
func (box *Box) PutAsync(object interface{}) (id uint64, err error) {
	return box.async.Put(object)
}
func (box *Box) Put(object interface{}) (id uint64, err error) {
	return box.put(object, false, cPutModePut)
}
func (box *Box) Insert(object interface{}) (id uint64, err error) {
	return box.put(object, false, cPutModeInsert)
}
func (box *Box) Update(object interface{}) error {
	_, err := box.put(object, false, cPutModeUpdate)
	return err
}
func (box *Box) PutMany(objects interface{}) (ids []uint64, err error) {
	var slice = reflect.ValueOf(objects)
	var count = slice.Len()
	if count == 0 {
		return []uint64{}, nil
	}
	ids = make([]uint64, count)
	err = box.ObjectBox.RunInWriteTx(func() error {
		if supportsResultArray {
			const chunkSize = 10000  
			var chunks = count / chunkSize
			if count%chunkSize != 0 {
				chunks = chunks + 1
			}
			for c := 0; c < chunks; c++ {
				var start = c * chunkSize
				var end = start + chunkSize
				if end > count {
					end = count
				}
				if err := box.putManyObjects(slice, ids, start, end); err != nil {
					return err
				}
			}
		} else {
			for i := 0; i < count; i++ {
				id, err := box.put(slice.Index(i).Interface(), true, cPutModePut)
				if err != nil {
					return err
				}
				ids[i] = id
			}
		}
		return nil
	})
	if err != nil {
		ids = nil
	}
	return ids, err
}
func (box *Box) putManyObjects(objects reflect.Value, outIds []uint64, start, end int) error {
	var binding = box.entity.binding
	var count = end - start
	var indexesNewObjects = make([]int, 0)
	var putMode = cPutModePutIdGuaranteedToBeNew
	for i := 0; i < count; i++ {
		var index = start + i
		var object = objects.Index(index).Interface()
		if id, err := binding.GetId(object); err != nil {
			return err
		} else if id > 0 {
			outIds[index] = id
			putMode = cPutModePut
		} else {
			indexesNewObjects = append(indexesNewObjects, index)
		}
	}
	firstNewId, err := box.idsForPut(len(indexesNewObjects))
	if err != nil {
		return err
	}
	for i := 0; i < len(indexesNewObjects); i++ {
		outIds[indexesNewObjects[i]] = firstNewId + uint64(i)
	}
	var objectsBytes = make([][]byte, count)
	for i := 0; i < count; i++ {
		var key = start + i
		var object = objects.Index(key).Interface()
		if box.entity.hasRelations {
			if err := binding.PutRelated(box.ObjectBox, object, outIds[key]); err != nil {
				return err
			}
		}
		if err := box.withObjectBytes(object, outIds[key], func(bytes []byte) error {
			objectsBytes[i] = make([]byte, len(bytes))
			copy(objectsBytes[i], bytes)
			return nil
		}); err != nil {
			return err
		}
	}
	bytesArray, err := goBytesArrayToC(objectsBytes)
	if err != nil {
		return err
	}
	defer bytesArray.free()
	idsArray := goUint64ArrayToCObxId(outIds[start:end])
	if err := cCall(func() C.obx_err {
		return C.obx_box_put_many(box.cBox, bytesArray.cBytesArray, idsArray, C.OBXPutMode(putMode))
	}); err != nil {
		return err
	}
	for _, index := range indexesNewObjects {
		if err := binding.SetId(objects.Index(index).Interface(), outIds[index]); err != nil {
			return fmt.Errorf("setting ID on objects[%v] failed: %s", index, err)
		}
	}
	return nil
}
func (box *Box) Remove(object interface{}) error {
	id, err := box.entity.binding.GetId(object)
	if err != nil {
		return err
	}
	return box.RemoveId(id)
}
func (box *Box) RemoveId(id uint64) error {
	return cCall(func() C.obx_err {
		return C.obx_box_remove(box.cBox, C.obx_id(id))
	})
}
func (box *Box) RemoveIds(ids ...uint64) (uint64, error) {
	cIds, err := goIdsArrayToC(ids)
	if err != nil {
		return 0, err
	}
	var cResult C.uint64_t
	err = cCall(func() C.obx_err {
		return C.obx_box_remove_many(box.cBox, cIds.cArray, &cResult)
	})
	return uint64(cResult), err
}
func (box *Box) RemoveAll() error {
	return cCall(func() C.obx_err {
		return C.obx_box_remove_all(box.cBox, nil)
	})
}
func (box *Box) Count() (uint64, error) {
	return box.CountMax(0)
}
func (box *Box) CountMax(limit uint64) (uint64, error) {
	var cResult C.uint64_t
	if err := cCall(func() C.obx_err { return C.obx_box_count(box.cBox, C.uint64_t(limit), &cResult) }); err != nil {
		return 0, err
	}
	return uint64(cResult), nil
}
func (box *Box) IsEmpty() (bool, error) {
	var cResult C.bool
	if err := cCall(func() C.obx_err { return C.obx_box_is_empty(box.cBox, &cResult) }); err != nil {
		return false, err
	}
	return bool(cResult), nil
}
func (box *Box) Get(id uint64) (object interface{}, err error) {
	err = box.ObjectBox.RunInReadTx(func() error {
		var data *C.void
		var dataSize C.size_t
		var dataPtr = unsafe.Pointer(data)
		var rc = C.obx_box_get(box.cBox, C.obx_id(id), &dataPtr, &dataSize)
		if rc == 0 {
			var bytes []byte
			cVoidPtrToByteSlice(dataPtr, int(dataSize), &bytes)
			object, err = box.entity.binding.Load(box.ObjectBox, bytes)
			return err
		} else if rc == C.OBX_NOT_FOUND {
			object = nil
			return nil
		} else {
			object = nil
			return createError()
		}
	})
	return object, err
}
func (box *Box) GetMany(ids ...uint64) (slice interface{}, err error) {
	const existingOnly = false
	if cIds, err := goIdsArrayToC(ids); err != nil {
		return nil, err
	} else if supportsResultArray {
		return box.readManyObjects(existingOnly, func() *C.OBX_bytes_array { return C.obx_box_get_many(box.cBox, cIds.cArray) })
	} else {
		var cFn = func(visitorArg unsafe.Pointer) C.obx_err {
			return C.obx_box_visit_many(box.cBox, cIds.cArray, dataVisitor, visitorArg)
		}
		return box.readUsingVisitor(existingOnly, cFn)
	}
}
func (box *Box) GetManyExisting(ids ...uint64) (slice interface{}, err error) {
	const existingOnly = true
	if cIds, err := goIdsArrayToC(ids); err != nil {
		return nil, err
	} else if supportsResultArray {
		return box.readManyObjects(existingOnly, func() *C.OBX_bytes_array { return C.obx_box_get_many(box.cBox, cIds.cArray) })
	} else {
		var cFn = func(visitorArg unsafe.Pointer) C.obx_err {
			return C.obx_box_visit_many(box.cBox, cIds.cArray, dataVisitor, visitorArg)
		}
		return box.readUsingVisitor(existingOnly, cFn)
	}
}
func (box *Box) GetAll() (slice interface{}, err error) {
	const existingOnly = true
	if supportsResultArray {
		return box.readManyObjects(existingOnly, func() *C.OBX_bytes_array { return C.obx_box_get_all(box.cBox) })
	}
	var cFn = func(visitorArg unsafe.Pointer) C.obx_err {
		return C.obx_box_visit_all(box.cBox, dataVisitor, visitorArg)
	}
	return box.readUsingVisitor(existingOnly, cFn)
}
func (box *Box) readManyObjects(existingOnly bool, cFn func() *C.OBX_bytes_array) (slice interface{}, err error) {
	err = box.ObjectBox.RunInReadTx(func() error {
		bytesArray, err := cGetBytesArray(cFn)
		if err != nil {
			return err
		}
		var binding = box.entity.binding
		slice = binding.MakeSlice(len(bytesArray))
		for _, bytesData := range bytesArray {
			if bytesData == nil {
				if !existingOnly {
					slice = binding.AppendToSlice(slice, nil)
				}
				continue
			}
			object, err := binding.Load(box.ObjectBox, bytesData)
			if err != nil {
				return err
			}
			slice = binding.AppendToSlice(slice, object)
		}
		return nil
	})
	if err != nil {
		slice = nil
	}
	return slice, err
}
func (box *Box) readUsingVisitor(existingOnly bool, cFn func(visitorArg unsafe.Pointer) C.obx_err) (slice interface{}, err error) {
	var binding = box.entity.binding
	var visitor uint32
	visitor, err = dataVisitorRegister(func(bytes []byte) bool {
		if bytes == nil {
			if !existingOnly {
				slice = binding.AppendToSlice(slice, nil)
			}
			return true
		}
		object, err2 := binding.Load(box.ObjectBox, bytes)
		if err2 != nil {
			err = err2
			return false
		}
		slice = binding.AppendToSlice(slice, object)
		return true
	})
	if err != nil {
		return nil, err
	}
	defer dataVisitorUnregister(visitor)
	slice = binding.MakeSlice(defaultSliceCapacity)
	var err2 = box.ObjectBox.RunInReadTx(func() error {
		return cCall(func() C.obx_err { return cFn(unsafe.Pointer(&visitor)) })
	})
	if err2 != nil {
		return nil, err2
	} else if err != nil {
		return nil, err
	} else {
		return slice, nil
	}
}