/
timeseries.obx.go
691 lines (603 loc) · 25 KB
/
timeseries.obx.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
// Code generated by ObjectBox; DO NOT EDIT.
// Learn more about defining entities and generating this file - visit https://golang.objectbox.io/entity-annotations
package model
import (
"errors"
"github.com/google/flatbuffers/go"
"github.com/objectbox/objectbox-go/objectbox"
"github.com/objectbox/objectbox-go/objectbox/fbutils"
)
type tSDate_EntityInfo struct {
objectbox.Entity
Uid uint64
}
var TSDateBinding = tSDate_EntityInfo{
Entity: objectbox.Entity{
Id: 6,
},
Uid: 2767047163049667536,
}
// TSDate_ contains type-based Property helpers to facilitate some common operations such as Queries.
var TSDate_ = struct {
Id *objectbox.PropertyUint64
Time *objectbox.PropertyInt64
}{
Id: &objectbox.PropertyUint64{
BaseProperty: &objectbox.BaseProperty{
Id: 1,
Entity: &TSDateBinding.Entity,
},
},
Time: &objectbox.PropertyInt64{
BaseProperty: &objectbox.BaseProperty{
Id: 2,
Entity: &TSDateBinding.Entity,
},
},
}
// GeneratorVersion is called by ObjectBox to verify the compatibility of the generator used to generate this code
func (tSDate_EntityInfo) GeneratorVersion() int {
return 6
}
// AddToModel is called by ObjectBox during model build
func (tSDate_EntityInfo) AddToModel(model *objectbox.Model) {
model.Entity("TSDate", 6, 2767047163049667536)
model.Property("Id", 6, 1, 1462677146136716215)
model.PropertyFlags(1)
model.Property("Time", 10, 2, 180851766275559029)
model.PropertyFlags(16384)
model.EntityLastPropertyId(2, 180851766275559029)
}
// GetId is called by ObjectBox during Put operations to check for existing ID on an object
func (tSDate_EntityInfo) GetId(object interface{}) (uint64, error) {
return object.(*TSDate).Id, nil
}
// SetId is called by ObjectBox during Put to update an ID on an object that has just been inserted
func (tSDate_EntityInfo) SetId(object interface{}, id uint64) error {
object.(*TSDate).Id = id
return nil
}
// PutRelated is called by ObjectBox to put related entities before the object itself is flattened and put
func (tSDate_EntityInfo) PutRelated(ob *objectbox.ObjectBox, object interface{}, id uint64) error {
return nil
}
// Flatten is called by ObjectBox to transform an object to a FlatBuffer
func (tSDate_EntityInfo) Flatten(object interface{}, fbb *flatbuffers.Builder, id uint64) error {
obj := object.(*TSDate)
var propTime int64
{
var err error
propTime, err = objectbox.TimeInt64ConvertToDatabaseValue(obj.Time)
if err != nil {
return errors.New("converter objectbox.TimeInt64ConvertToDatabaseValue() failed on TSDate.Time: " + err.Error())
}
}
// build the FlatBuffers object
fbb.StartObject(2)
fbutils.SetUint64Slot(fbb, 0, id)
fbutils.SetInt64Slot(fbb, 1, propTime)
return nil
}
// Load is called by ObjectBox to load an object from a FlatBuffer
func (tSDate_EntityInfo) Load(ob *objectbox.ObjectBox, bytes []byte) (interface{}, error) {
if len(bytes) == 0 { // sanity check, should "never" happen
return nil, errors.New("can't deserialize an object of type 'TSDate' - no data received")
}
var table = &flatbuffers.Table{
Bytes: bytes,
Pos: flatbuffers.GetUOffsetT(bytes),
}
var propId = table.GetUint64Slot(4, 0)
propTime, err := objectbox.TimeInt64ConvertToEntityProperty(fbutils.GetInt64Slot(table, 6))
if err != nil {
return nil, errors.New("converter objectbox.TimeInt64ConvertToEntityProperty() failed on TSDate.Time: " + err.Error())
}
return &TSDate{
Id: propId,
Time: propTime,
}, nil
}
// MakeSlice is called by ObjectBox to construct a new slice to hold the read objects
func (tSDate_EntityInfo) MakeSlice(capacity int) interface{} {
return make([]*TSDate, 0, capacity)
}
// AppendToSlice is called by ObjectBox to fill the slice of the read objects
func (tSDate_EntityInfo) AppendToSlice(slice interface{}, object interface{}) interface{} {
if object == nil {
return append(slice.([]*TSDate), nil)
}
return append(slice.([]*TSDate), object.(*TSDate))
}
// Box provides CRUD access to TSDate objects
type TSDateBox struct {
*objectbox.Box
}
// BoxForTSDate opens a box of TSDate objects
func BoxForTSDate(ob *objectbox.ObjectBox) *TSDateBox {
return &TSDateBox{
Box: ob.InternalBox(6),
}
}
// Put synchronously inserts/updates a single object.
// In case the Id is not specified, it would be assigned automatically (auto-increment).
// When inserting, the TSDate.Id property on the passed object will be assigned the new ID as well.
func (box *TSDateBox) Put(object *TSDate) (uint64, error) {
return box.Box.Put(object)
}
// 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 TSDate.Id property on the passed object will be assigned the new ID as well.
func (box *TSDateBox) Insert(object *TSDate) (uint64, error) {
return box.Box.Insert(object)
}
// Update synchronously updates a single object.
// As opposed to Put, Update will fail if an object with the same ID is not found in the database.
func (box *TSDateBox) Update(object *TSDate) error {
return box.Box.Update(object)
}
// PutAsync asynchronously inserts/updates a single object.
// Deprecated: use box.Async().Put() instead
func (box *TSDateBox) PutAsync(object *TSDate) (uint64, error) {
return box.Box.PutAsync(object)
}
// 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 TSDate.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 TSDate.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 (box *TSDateBox) PutMany(objects []*TSDate) ([]uint64, error) {
return box.Box.PutMany(objects)
}
// Get reads a single object.
//
// Returns nil (and no error) in case the object with the given ID doesn't exist.
func (box *TSDateBox) Get(id uint64) (*TSDate, error) {
object, err := box.Box.Get(id)
if err != nil {
return nil, err
} else if object == nil {
return nil, nil
}
return object.(*TSDate), nil
}
// GetMany reads multiple objects at once.
// If any of the objects doesn't exist, its position in the return slice is nil
func (box *TSDateBox) GetMany(ids ...uint64) ([]*TSDate, error) {
objects, err := box.Box.GetMany(ids...)
if err != nil {
return nil, err
}
return objects.([]*TSDate), nil
}
// GetManyExisting reads multiple objects at once, skipping those that do not exist.
func (box *TSDateBox) GetManyExisting(ids ...uint64) ([]*TSDate, error) {
objects, err := box.Box.GetManyExisting(ids...)
if err != nil {
return nil, err
}
return objects.([]*TSDate), nil
}
// GetAll reads all stored objects
func (box *TSDateBox) GetAll() ([]*TSDate, error) {
objects, err := box.Box.GetAll()
if err != nil {
return nil, err
}
return objects.([]*TSDate), nil
}
// Remove deletes a single object
func (box *TSDateBox) Remove(object *TSDate) error {
return box.Box.Remove(object)
}
// 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.
func (box *TSDateBox) RemoveMany(objects ...*TSDate) (uint64, error) {
var ids = make([]uint64, len(objects))
for k, object := range objects {
ids[k] = object.Id
}
return box.Box.RemoveIds(ids...)
}
// Creates a query with the given conditions. Use the fields of the TSDate_ struct to create conditions.
// Keep the *TSDateQuery 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 (box *TSDateBox) Query(conditions ...objectbox.Condition) *TSDateQuery {
return &TSDateQuery{
box.Box.Query(conditions...),
}
}
// Creates a query with the given conditions. Use the fields of the TSDate_ struct to create conditions.
// Keep the *TSDateQuery if you intend to execute the query multiple times.
func (box *TSDateBox) QueryOrError(conditions ...objectbox.Condition) (*TSDateQuery, error) {
if query, err := box.Box.QueryOrError(conditions...); err != nil {
return nil, err
} else {
return &TSDateQuery{query}, nil
}
}
// Async provides access to the default Async Box for asynchronous operations. See TSDateAsyncBox for more information.
func (box *TSDateBox) Async() *TSDateAsyncBox {
return &TSDateAsyncBox{AsyncBox: box.Box.Async()}
}
// TSDateAsyncBox provides asynchronous operations on TSDate 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.
type TSDateAsyncBox struct {
*objectbox.AsyncBox
}
// AsyncBoxForTSDate 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 TSDateBox::Async() which takes care of resource management and doesn't require closing.
func AsyncBoxForTSDate(ob *objectbox.ObjectBox, timeoutMs uint64) *TSDateAsyncBox {
var async, err = objectbox.NewAsyncBox(ob, 6, timeoutMs)
if err != nil {
panic("Could not create async box for entity ID 6: %s" + err.Error())
}
return &TSDateAsyncBox{AsyncBox: async}
}
// 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 (asyncBox *TSDateAsyncBox) Put(object *TSDate) (uint64, error) {
return asyncBox.AsyncBox.Put(object)
}
// 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 (asyncBox *TSDateAsyncBox) Insert(object *TSDate) (id uint64, err error) {
return asyncBox.AsyncBox.Insert(object)
}
// Update a single object asynchronously.
// The object must already exists or the update fails silently (without an error returned).
func (asyncBox *TSDateAsyncBox) Update(object *TSDate) error {
return asyncBox.AsyncBox.Update(object)
}
// Remove deletes a single object asynchronously.
func (asyncBox *TSDateAsyncBox) Remove(object *TSDate) error {
return asyncBox.AsyncBox.Remove(object)
}
// Query provides a way to search stored objects
//
// For example, you can find all TSDate which Id is either 42 or 47:
// box.Query(TSDate_.Id.In(42, 47)).Find()
type TSDateQuery struct {
*objectbox.Query
}
// Find returns all objects matching the query
func (query *TSDateQuery) Find() ([]*TSDate, error) {
objects, err := query.Query.Find()
if err != nil {
return nil, err
}
return objects.([]*TSDate), nil
}
// Offset defines the index of the first object to process (how many objects to skip)
func (query *TSDateQuery) Offset(offset uint64) *TSDateQuery {
query.Query.Offset(offset)
return query
}
// Limit sets the number of elements to process by the query
func (query *TSDateQuery) Limit(limit uint64) *TSDateQuery {
query.Query.Limit(limit)
return query
}
type tSDateNano_EntityInfo struct {
objectbox.Entity
Uid uint64
}
var TSDateNanoBinding = tSDateNano_EntityInfo{
Entity: objectbox.Entity{
Id: 7,
},
Uid: 8200223062288330287,
}
// TSDateNano_ contains type-based Property helpers to facilitate some common operations such as Queries.
var TSDateNano_ = struct {
Id *objectbox.PropertyUint64
Time *objectbox.PropertyInt64
}{
Id: &objectbox.PropertyUint64{
BaseProperty: &objectbox.BaseProperty{
Id: 1,
Entity: &TSDateNanoBinding.Entity,
},
},
Time: &objectbox.PropertyInt64{
BaseProperty: &objectbox.BaseProperty{
Id: 2,
Entity: &TSDateNanoBinding.Entity,
},
},
}
// GeneratorVersion is called by ObjectBox to verify the compatibility of the generator used to generate this code
func (tSDateNano_EntityInfo) GeneratorVersion() int {
return 6
}
// AddToModel is called by ObjectBox during model build
func (tSDateNano_EntityInfo) AddToModel(model *objectbox.Model) {
model.Entity("TSDateNano", 7, 8200223062288330287)
model.Property("Id", 6, 1, 7438841713427308701)
model.PropertyFlags(1)
model.Property("Time", 12, 2, 6159670697406080312)
model.PropertyFlags(16384)
model.EntityLastPropertyId(2, 6159670697406080312)
}
// GetId is called by ObjectBox during Put operations to check for existing ID on an object
func (tSDateNano_EntityInfo) GetId(object interface{}) (uint64, error) {
return object.(*TSDateNano).Id, nil
}
// SetId is called by ObjectBox during Put to update an ID on an object that has just been inserted
func (tSDateNano_EntityInfo) SetId(object interface{}, id uint64) error {
object.(*TSDateNano).Id = id
return nil
}
// PutRelated is called by ObjectBox to put related entities before the object itself is flattened and put
func (tSDateNano_EntityInfo) PutRelated(ob *objectbox.ObjectBox, object interface{}, id uint64) error {
return nil
}
// Flatten is called by ObjectBox to transform an object to a FlatBuffer
func (tSDateNano_EntityInfo) Flatten(object interface{}, fbb *flatbuffers.Builder, id uint64) error {
obj := object.(*TSDateNano)
var propTime int64
{
var err error
propTime, err = objectbox.NanoTimeInt64ConvertToDatabaseValue(obj.Time)
if err != nil {
return errors.New("converter objectbox.NanoTimeInt64ConvertToDatabaseValue() failed on TSDateNano.Time: " + err.Error())
}
}
// build the FlatBuffers object
fbb.StartObject(2)
fbutils.SetUint64Slot(fbb, 0, id)
fbutils.SetInt64Slot(fbb, 1, propTime)
return nil
}
// Load is called by ObjectBox to load an object from a FlatBuffer
func (tSDateNano_EntityInfo) Load(ob *objectbox.ObjectBox, bytes []byte) (interface{}, error) {
if len(bytes) == 0 { // sanity check, should "never" happen
return nil, errors.New("can't deserialize an object of type 'TSDateNano' - no data received")
}
var table = &flatbuffers.Table{
Bytes: bytes,
Pos: flatbuffers.GetUOffsetT(bytes),
}
var propId = table.GetUint64Slot(4, 0)
propTime, err := objectbox.NanoTimeInt64ConvertToEntityProperty(fbutils.GetInt64Slot(table, 6))
if err != nil {
return nil, errors.New("converter objectbox.NanoTimeInt64ConvertToEntityProperty() failed on TSDateNano.Time: " + err.Error())
}
return &TSDateNano{
Id: propId,
Time: propTime,
}, nil
}
// MakeSlice is called by ObjectBox to construct a new slice to hold the read objects
func (tSDateNano_EntityInfo) MakeSlice(capacity int) interface{} {
return make([]*TSDateNano, 0, capacity)
}
// AppendToSlice is called by ObjectBox to fill the slice of the read objects
func (tSDateNano_EntityInfo) AppendToSlice(slice interface{}, object interface{}) interface{} {
if object == nil {
return append(slice.([]*TSDateNano), nil)
}
return append(slice.([]*TSDateNano), object.(*TSDateNano))
}
// Box provides CRUD access to TSDateNano objects
type TSDateNanoBox struct {
*objectbox.Box
}
// BoxForTSDateNano opens a box of TSDateNano objects
func BoxForTSDateNano(ob *objectbox.ObjectBox) *TSDateNanoBox {
return &TSDateNanoBox{
Box: ob.InternalBox(7),
}
}
// Put synchronously inserts/updates a single object.
// In case the Id is not specified, it would be assigned automatically (auto-increment).
// When inserting, the TSDateNano.Id property on the passed object will be assigned the new ID as well.
func (box *TSDateNanoBox) Put(object *TSDateNano) (uint64, error) {
return box.Box.Put(object)
}
// 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 TSDateNano.Id property on the passed object will be assigned the new ID as well.
func (box *TSDateNanoBox) Insert(object *TSDateNano) (uint64, error) {
return box.Box.Insert(object)
}
// Update synchronously updates a single object.
// As opposed to Put, Update will fail if an object with the same ID is not found in the database.
func (box *TSDateNanoBox) Update(object *TSDateNano) error {
return box.Box.Update(object)
}
// PutAsync asynchronously inserts/updates a single object.
// Deprecated: use box.Async().Put() instead
func (box *TSDateNanoBox) PutAsync(object *TSDateNano) (uint64, error) {
return box.Box.PutAsync(object)
}
// 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 TSDateNano.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 TSDateNano.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 (box *TSDateNanoBox) PutMany(objects []*TSDateNano) ([]uint64, error) {
return box.Box.PutMany(objects)
}
// Get reads a single object.
//
// Returns nil (and no error) in case the object with the given ID doesn't exist.
func (box *TSDateNanoBox) Get(id uint64) (*TSDateNano, error) {
object, err := box.Box.Get(id)
if err != nil {
return nil, err
} else if object == nil {
return nil, nil
}
return object.(*TSDateNano), nil
}
// GetMany reads multiple objects at once.
// If any of the objects doesn't exist, its position in the return slice is nil
func (box *TSDateNanoBox) GetMany(ids ...uint64) ([]*TSDateNano, error) {
objects, err := box.Box.GetMany(ids...)
if err != nil {
return nil, err
}
return objects.([]*TSDateNano), nil
}
// GetManyExisting reads multiple objects at once, skipping those that do not exist.
func (box *TSDateNanoBox) GetManyExisting(ids ...uint64) ([]*TSDateNano, error) {
objects, err := box.Box.GetManyExisting(ids...)
if err != nil {
return nil, err
}
return objects.([]*TSDateNano), nil
}
// GetAll reads all stored objects
func (box *TSDateNanoBox) GetAll() ([]*TSDateNano, error) {
objects, err := box.Box.GetAll()
if err != nil {
return nil, err
}
return objects.([]*TSDateNano), nil
}
// Remove deletes a single object
func (box *TSDateNanoBox) Remove(object *TSDateNano) error {
return box.Box.Remove(object)
}
// 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.
func (box *TSDateNanoBox) RemoveMany(objects ...*TSDateNano) (uint64, error) {
var ids = make([]uint64, len(objects))
for k, object := range objects {
ids[k] = object.Id
}
return box.Box.RemoveIds(ids...)
}
// Creates a query with the given conditions. Use the fields of the TSDateNano_ struct to create conditions.
// Keep the *TSDateNanoQuery 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 (box *TSDateNanoBox) Query(conditions ...objectbox.Condition) *TSDateNanoQuery {
return &TSDateNanoQuery{
box.Box.Query(conditions...),
}
}
// Creates a query with the given conditions. Use the fields of the TSDateNano_ struct to create conditions.
// Keep the *TSDateNanoQuery if you intend to execute the query multiple times.
func (box *TSDateNanoBox) QueryOrError(conditions ...objectbox.Condition) (*TSDateNanoQuery, error) {
if query, err := box.Box.QueryOrError(conditions...); err != nil {
return nil, err
} else {
return &TSDateNanoQuery{query}, nil
}
}
// Async provides access to the default Async Box for asynchronous operations. See TSDateNanoAsyncBox for more information.
func (box *TSDateNanoBox) Async() *TSDateNanoAsyncBox {
return &TSDateNanoAsyncBox{AsyncBox: box.Box.Async()}
}
// TSDateNanoAsyncBox provides asynchronous operations on TSDateNano 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.
type TSDateNanoAsyncBox struct {
*objectbox.AsyncBox
}
// AsyncBoxForTSDateNano 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 TSDateNanoBox::Async() which takes care of resource management and doesn't require closing.
func AsyncBoxForTSDateNano(ob *objectbox.ObjectBox, timeoutMs uint64) *TSDateNanoAsyncBox {
var async, err = objectbox.NewAsyncBox(ob, 7, timeoutMs)
if err != nil {
panic("Could not create async box for entity ID 7: %s" + err.Error())
}
return &TSDateNanoAsyncBox{AsyncBox: async}
}
// 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 (asyncBox *TSDateNanoAsyncBox) Put(object *TSDateNano) (uint64, error) {
return asyncBox.AsyncBox.Put(object)
}
// 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 (asyncBox *TSDateNanoAsyncBox) Insert(object *TSDateNano) (id uint64, err error) {
return asyncBox.AsyncBox.Insert(object)
}
// Update a single object asynchronously.
// The object must already exists or the update fails silently (without an error returned).
func (asyncBox *TSDateNanoAsyncBox) Update(object *TSDateNano) error {
return asyncBox.AsyncBox.Update(object)
}
// Remove deletes a single object asynchronously.
func (asyncBox *TSDateNanoAsyncBox) Remove(object *TSDateNano) error {
return asyncBox.AsyncBox.Remove(object)
}
// Query provides a way to search stored objects
//
// For example, you can find all TSDateNano which Id is either 42 or 47:
// box.Query(TSDateNano_.Id.In(42, 47)).Find()
type TSDateNanoQuery struct {
*objectbox.Query
}
// Find returns all objects matching the query
func (query *TSDateNanoQuery) Find() ([]*TSDateNano, error) {
objects, err := query.Query.Find()
if err != nil {
return nil, err
}
return objects.([]*TSDateNano), nil
}
// Offset defines the index of the first object to process (how many objects to skip)
func (query *TSDateNanoQuery) Offset(offset uint64) *TSDateNanoQuery {
query.Query.Offset(offset)
return query
}
// Limit sets the number of elements to process by the query
func (query *TSDateNanoQuery) Limit(limit uint64) *TSDateNanoQuery {
query.Query.Limit(limit)
return query
}