-
Notifications
You must be signed in to change notification settings - Fork 101
/
state.cosmos_orm.go
1932 lines (1556 loc) · 64.9 KB
/
state.cosmos_orm.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
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Code generated by protoc-gen-go-cosmos-orm. DO NOT EDIT.
package ecocreditv1
import (
context "context"
ormlist "github.com/cosmos/cosmos-sdk/orm/model/ormlist"
ormtable "github.com/cosmos/cosmos-sdk/orm/model/ormtable"
ormerrors "github.com/cosmos/cosmos-sdk/orm/types/ormerrors"
timestamppb "google.golang.org/protobuf/types/known/timestamppb"
)
type CreditTypeTable interface {
Insert(ctx context.Context, creditType *CreditType) error
Update(ctx context.Context, creditType *CreditType) error
Save(ctx context.Context, creditType *CreditType) error
Delete(ctx context.Context, creditType *CreditType) error
Has(ctx context.Context, abbreviation string) (found bool, err error)
// Get returns nil and an error which responds true to ormerrors.IsNotFound() if the record was not found.
Get(ctx context.Context, abbreviation string) (*CreditType, error)
HasByName(ctx context.Context, name string) (found bool, err error)
// GetByName returns nil and an error which responds true to ormerrors.IsNotFound() if the record was not found.
GetByName(ctx context.Context, name string) (*CreditType, error)
List(ctx context.Context, prefixKey CreditTypeIndexKey, opts ...ormlist.Option) (CreditTypeIterator, error)
ListRange(ctx context.Context, from, to CreditTypeIndexKey, opts ...ormlist.Option) (CreditTypeIterator, error)
DeleteBy(ctx context.Context, prefixKey CreditTypeIndexKey) error
DeleteRange(ctx context.Context, from, to CreditTypeIndexKey) error
doNotImplement()
}
type CreditTypeIterator struct {
ormtable.Iterator
}
func (i CreditTypeIterator) Value() (*CreditType, error) {
var creditType CreditType
err := i.UnmarshalMessage(&creditType)
return &creditType, err
}
type CreditTypeIndexKey interface {
id() uint32
values() []interface{}
creditTypeIndexKey()
}
// primary key starting index..
type CreditTypePrimaryKey = CreditTypeAbbreviationIndexKey
type CreditTypeAbbreviationIndexKey struct {
vs []interface{}
}
func (x CreditTypeAbbreviationIndexKey) id() uint32 { return 0 }
func (x CreditTypeAbbreviationIndexKey) values() []interface{} { return x.vs }
func (x CreditTypeAbbreviationIndexKey) creditTypeIndexKey() {}
func (this CreditTypeAbbreviationIndexKey) WithAbbreviation(abbreviation string) CreditTypeAbbreviationIndexKey {
this.vs = []interface{}{abbreviation}
return this
}
type CreditTypeNameIndexKey struct {
vs []interface{}
}
func (x CreditTypeNameIndexKey) id() uint32 { return 1 }
func (x CreditTypeNameIndexKey) values() []interface{} { return x.vs }
func (x CreditTypeNameIndexKey) creditTypeIndexKey() {}
func (this CreditTypeNameIndexKey) WithName(name string) CreditTypeNameIndexKey {
this.vs = []interface{}{name}
return this
}
type creditTypeTable struct {
table ormtable.Table
}
func (this creditTypeTable) Insert(ctx context.Context, creditType *CreditType) error {
return this.table.Insert(ctx, creditType)
}
func (this creditTypeTable) Update(ctx context.Context, creditType *CreditType) error {
return this.table.Update(ctx, creditType)
}
func (this creditTypeTable) Save(ctx context.Context, creditType *CreditType) error {
return this.table.Save(ctx, creditType)
}
func (this creditTypeTable) Delete(ctx context.Context, creditType *CreditType) error {
return this.table.Delete(ctx, creditType)
}
func (this creditTypeTable) Has(ctx context.Context, abbreviation string) (found bool, err error) {
return this.table.PrimaryKey().Has(ctx, abbreviation)
}
func (this creditTypeTable) Get(ctx context.Context, abbreviation string) (*CreditType, error) {
var creditType CreditType
found, err := this.table.PrimaryKey().Get(ctx, &creditType, abbreviation)
if err != nil {
return nil, err
}
if !found {
return nil, ormerrors.NotFound
}
return &creditType, nil
}
func (this creditTypeTable) HasByName(ctx context.Context, name string) (found bool, err error) {
return this.table.GetIndexByID(1).(ormtable.UniqueIndex).Has(ctx,
name,
)
}
func (this creditTypeTable) GetByName(ctx context.Context, name string) (*CreditType, error) {
var creditType CreditType
found, err := this.table.GetIndexByID(1).(ormtable.UniqueIndex).Get(ctx, &creditType,
name,
)
if err != nil {
return nil, err
}
if !found {
return nil, ormerrors.NotFound
}
return &creditType, nil
}
func (this creditTypeTable) List(ctx context.Context, prefixKey CreditTypeIndexKey, opts ...ormlist.Option) (CreditTypeIterator, error) {
it, err := this.table.GetIndexByID(prefixKey.id()).List(ctx, prefixKey.values(), opts...)
return CreditTypeIterator{it}, err
}
func (this creditTypeTable) ListRange(ctx context.Context, from, to CreditTypeIndexKey, opts ...ormlist.Option) (CreditTypeIterator, error) {
it, err := this.table.GetIndexByID(from.id()).ListRange(ctx, from.values(), to.values(), opts...)
return CreditTypeIterator{it}, err
}
func (this creditTypeTable) DeleteBy(ctx context.Context, prefixKey CreditTypeIndexKey) error {
return this.table.GetIndexByID(prefixKey.id()).DeleteBy(ctx, prefixKey.values()...)
}
func (this creditTypeTable) DeleteRange(ctx context.Context, from, to CreditTypeIndexKey) error {
return this.table.GetIndexByID(from.id()).DeleteRange(ctx, from.values(), to.values())
}
func (this creditTypeTable) doNotImplement() {}
var _ CreditTypeTable = creditTypeTable{}
func NewCreditTypeTable(db ormtable.Schema) (CreditTypeTable, error) {
table := db.GetTable(&CreditType{})
if table == nil {
return nil, ormerrors.TableNotFound.Wrap(string((&CreditType{}).ProtoReflect().Descriptor().FullName()))
}
return creditTypeTable{table}, nil
}
type ClassTable interface {
Insert(ctx context.Context, class *Class) error
InsertReturningID(ctx context.Context, class *Class) (uint64, error)
Update(ctx context.Context, class *Class) error
Save(ctx context.Context, class *Class) error
Delete(ctx context.Context, class *Class) error
Has(ctx context.Context, key uint64) (found bool, err error)
// Get returns nil and an error which responds true to ormerrors.IsNotFound() if the record was not found.
Get(ctx context.Context, key uint64) (*Class, error)
HasById(ctx context.Context, id string) (found bool, err error)
// GetById returns nil and an error which responds true to ormerrors.IsNotFound() if the record was not found.
GetById(ctx context.Context, id string) (*Class, error)
List(ctx context.Context, prefixKey ClassIndexKey, opts ...ormlist.Option) (ClassIterator, error)
ListRange(ctx context.Context, from, to ClassIndexKey, opts ...ormlist.Option) (ClassIterator, error)
DeleteBy(ctx context.Context, prefixKey ClassIndexKey) error
DeleteRange(ctx context.Context, from, to ClassIndexKey) error
doNotImplement()
}
type ClassIterator struct {
ormtable.Iterator
}
func (i ClassIterator) Value() (*Class, error) {
var class Class
err := i.UnmarshalMessage(&class)
return &class, err
}
type ClassIndexKey interface {
id() uint32
values() []interface{}
classIndexKey()
}
// primary key starting index..
type ClassPrimaryKey = ClassKeyIndexKey
type ClassKeyIndexKey struct {
vs []interface{}
}
func (x ClassKeyIndexKey) id() uint32 { return 0 }
func (x ClassKeyIndexKey) values() []interface{} { return x.vs }
func (x ClassKeyIndexKey) classIndexKey() {}
func (this ClassKeyIndexKey) WithKey(key uint64) ClassKeyIndexKey {
this.vs = []interface{}{key}
return this
}
type ClassIdIndexKey struct {
vs []interface{}
}
func (x ClassIdIndexKey) id() uint32 { return 1 }
func (x ClassIdIndexKey) values() []interface{} { return x.vs }
func (x ClassIdIndexKey) classIndexKey() {}
func (this ClassIdIndexKey) WithId(id string) ClassIdIndexKey {
this.vs = []interface{}{id}
return this
}
type ClassAdminIndexKey struct {
vs []interface{}
}
func (x ClassAdminIndexKey) id() uint32 { return 2 }
func (x ClassAdminIndexKey) values() []interface{} { return x.vs }
func (x ClassAdminIndexKey) classIndexKey() {}
func (this ClassAdminIndexKey) WithAdmin(admin []byte) ClassAdminIndexKey {
this.vs = []interface{}{admin}
return this
}
type ClassCreditTypeAbbrevIndexKey struct {
vs []interface{}
}
func (x ClassCreditTypeAbbrevIndexKey) id() uint32 { return 3 }
func (x ClassCreditTypeAbbrevIndexKey) values() []interface{} { return x.vs }
func (x ClassCreditTypeAbbrevIndexKey) classIndexKey() {}
func (this ClassCreditTypeAbbrevIndexKey) WithCreditTypeAbbrev(credit_type_abbrev string) ClassCreditTypeAbbrevIndexKey {
this.vs = []interface{}{credit_type_abbrev}
return this
}
type classTable struct {
table ormtable.AutoIncrementTable
}
func (this classTable) Insert(ctx context.Context, class *Class) error {
return this.table.Insert(ctx, class)
}
func (this classTable) Update(ctx context.Context, class *Class) error {
return this.table.Update(ctx, class)
}
func (this classTable) Save(ctx context.Context, class *Class) error {
return this.table.Save(ctx, class)
}
func (this classTable) Delete(ctx context.Context, class *Class) error {
return this.table.Delete(ctx, class)
}
func (this classTable) InsertReturningID(ctx context.Context, class *Class) (uint64, error) {
return this.table.InsertReturningID(ctx, class)
}
func (this classTable) Has(ctx context.Context, key uint64) (found bool, err error) {
return this.table.PrimaryKey().Has(ctx, key)
}
func (this classTable) Get(ctx context.Context, key uint64) (*Class, error) {
var class Class
found, err := this.table.PrimaryKey().Get(ctx, &class, key)
if err != nil {
return nil, err
}
if !found {
return nil, ormerrors.NotFound
}
return &class, nil
}
func (this classTable) HasById(ctx context.Context, id string) (found bool, err error) {
return this.table.GetIndexByID(1).(ormtable.UniqueIndex).Has(ctx,
id,
)
}
func (this classTable) GetById(ctx context.Context, id string) (*Class, error) {
var class Class
found, err := this.table.GetIndexByID(1).(ormtable.UniqueIndex).Get(ctx, &class,
id,
)
if err != nil {
return nil, err
}
if !found {
return nil, ormerrors.NotFound
}
return &class, nil
}
func (this classTable) List(ctx context.Context, prefixKey ClassIndexKey, opts ...ormlist.Option) (ClassIterator, error) {
it, err := this.table.GetIndexByID(prefixKey.id()).List(ctx, prefixKey.values(), opts...)
return ClassIterator{it}, err
}
func (this classTable) ListRange(ctx context.Context, from, to ClassIndexKey, opts ...ormlist.Option) (ClassIterator, error) {
it, err := this.table.GetIndexByID(from.id()).ListRange(ctx, from.values(), to.values(), opts...)
return ClassIterator{it}, err
}
func (this classTable) DeleteBy(ctx context.Context, prefixKey ClassIndexKey) error {
return this.table.GetIndexByID(prefixKey.id()).DeleteBy(ctx, prefixKey.values()...)
}
func (this classTable) DeleteRange(ctx context.Context, from, to ClassIndexKey) error {
return this.table.GetIndexByID(from.id()).DeleteRange(ctx, from.values(), to.values())
}
func (this classTable) doNotImplement() {}
var _ ClassTable = classTable{}
func NewClassTable(db ormtable.Schema) (ClassTable, error) {
table := db.GetTable(&Class{})
if table == nil {
return nil, ormerrors.TableNotFound.Wrap(string((&Class{}).ProtoReflect().Descriptor().FullName()))
}
return classTable{table.(ormtable.AutoIncrementTable)}, nil
}
type ClassIssuerTable interface {
Insert(ctx context.Context, classIssuer *ClassIssuer) error
Update(ctx context.Context, classIssuer *ClassIssuer) error
Save(ctx context.Context, classIssuer *ClassIssuer) error
Delete(ctx context.Context, classIssuer *ClassIssuer) error
Has(ctx context.Context, class_key uint64, issuer []byte) (found bool, err error)
// Get returns nil and an error which responds true to ormerrors.IsNotFound() if the record was not found.
Get(ctx context.Context, class_key uint64, issuer []byte) (*ClassIssuer, error)
List(ctx context.Context, prefixKey ClassIssuerIndexKey, opts ...ormlist.Option) (ClassIssuerIterator, error)
ListRange(ctx context.Context, from, to ClassIssuerIndexKey, opts ...ormlist.Option) (ClassIssuerIterator, error)
DeleteBy(ctx context.Context, prefixKey ClassIssuerIndexKey) error
DeleteRange(ctx context.Context, from, to ClassIssuerIndexKey) error
doNotImplement()
}
type ClassIssuerIterator struct {
ormtable.Iterator
}
func (i ClassIssuerIterator) Value() (*ClassIssuer, error) {
var classIssuer ClassIssuer
err := i.UnmarshalMessage(&classIssuer)
return &classIssuer, err
}
type ClassIssuerIndexKey interface {
id() uint32
values() []interface{}
classIssuerIndexKey()
}
// primary key starting index..
type ClassIssuerPrimaryKey = ClassIssuerClassKeyIssuerIndexKey
type ClassIssuerClassKeyIssuerIndexKey struct {
vs []interface{}
}
func (x ClassIssuerClassKeyIssuerIndexKey) id() uint32 { return 0 }
func (x ClassIssuerClassKeyIssuerIndexKey) values() []interface{} { return x.vs }
func (x ClassIssuerClassKeyIssuerIndexKey) classIssuerIndexKey() {}
func (this ClassIssuerClassKeyIssuerIndexKey) WithClassKey(class_key uint64) ClassIssuerClassKeyIssuerIndexKey {
this.vs = []interface{}{class_key}
return this
}
func (this ClassIssuerClassKeyIssuerIndexKey) WithClassKeyIssuer(class_key uint64, issuer []byte) ClassIssuerClassKeyIssuerIndexKey {
this.vs = []interface{}{class_key, issuer}
return this
}
type classIssuerTable struct {
table ormtable.Table
}
func (this classIssuerTable) Insert(ctx context.Context, classIssuer *ClassIssuer) error {
return this.table.Insert(ctx, classIssuer)
}
func (this classIssuerTable) Update(ctx context.Context, classIssuer *ClassIssuer) error {
return this.table.Update(ctx, classIssuer)
}
func (this classIssuerTable) Save(ctx context.Context, classIssuer *ClassIssuer) error {
return this.table.Save(ctx, classIssuer)
}
func (this classIssuerTable) Delete(ctx context.Context, classIssuer *ClassIssuer) error {
return this.table.Delete(ctx, classIssuer)
}
func (this classIssuerTable) Has(ctx context.Context, class_key uint64, issuer []byte) (found bool, err error) {
return this.table.PrimaryKey().Has(ctx, class_key, issuer)
}
func (this classIssuerTable) Get(ctx context.Context, class_key uint64, issuer []byte) (*ClassIssuer, error) {
var classIssuer ClassIssuer
found, err := this.table.PrimaryKey().Get(ctx, &classIssuer, class_key, issuer)
if err != nil {
return nil, err
}
if !found {
return nil, ormerrors.NotFound
}
return &classIssuer, nil
}
func (this classIssuerTable) List(ctx context.Context, prefixKey ClassIssuerIndexKey, opts ...ormlist.Option) (ClassIssuerIterator, error) {
it, err := this.table.GetIndexByID(prefixKey.id()).List(ctx, prefixKey.values(), opts...)
return ClassIssuerIterator{it}, err
}
func (this classIssuerTable) ListRange(ctx context.Context, from, to ClassIssuerIndexKey, opts ...ormlist.Option) (ClassIssuerIterator, error) {
it, err := this.table.GetIndexByID(from.id()).ListRange(ctx, from.values(), to.values(), opts...)
return ClassIssuerIterator{it}, err
}
func (this classIssuerTable) DeleteBy(ctx context.Context, prefixKey ClassIssuerIndexKey) error {
return this.table.GetIndexByID(prefixKey.id()).DeleteBy(ctx, prefixKey.values()...)
}
func (this classIssuerTable) DeleteRange(ctx context.Context, from, to ClassIssuerIndexKey) error {
return this.table.GetIndexByID(from.id()).DeleteRange(ctx, from.values(), to.values())
}
func (this classIssuerTable) doNotImplement() {}
var _ ClassIssuerTable = classIssuerTable{}
func NewClassIssuerTable(db ormtable.Schema) (ClassIssuerTable, error) {
table := db.GetTable(&ClassIssuer{})
if table == nil {
return nil, ormerrors.TableNotFound.Wrap(string((&ClassIssuer{}).ProtoReflect().Descriptor().FullName()))
}
return classIssuerTable{table}, nil
}
type ProjectTable interface {
Insert(ctx context.Context, project *Project) error
InsertReturningID(ctx context.Context, project *Project) (uint64, error)
Update(ctx context.Context, project *Project) error
Save(ctx context.Context, project *Project) error
Delete(ctx context.Context, project *Project) error
Has(ctx context.Context, key uint64) (found bool, err error)
// Get returns nil and an error which responds true to ormerrors.IsNotFound() if the record was not found.
Get(ctx context.Context, key uint64) (*Project, error)
HasById(ctx context.Context, id string) (found bool, err error)
// GetById returns nil and an error which responds true to ormerrors.IsNotFound() if the record was not found.
GetById(ctx context.Context, id string) (*Project, error)
HasByClassKeyId(ctx context.Context, class_key uint64, id string) (found bool, err error)
// GetByClassKeyId returns nil and an error which responds true to ormerrors.IsNotFound() if the record was not found.
GetByClassKeyId(ctx context.Context, class_key uint64, id string) (*Project, error)
List(ctx context.Context, prefixKey ProjectIndexKey, opts ...ormlist.Option) (ProjectIterator, error)
ListRange(ctx context.Context, from, to ProjectIndexKey, opts ...ormlist.Option) (ProjectIterator, error)
DeleteBy(ctx context.Context, prefixKey ProjectIndexKey) error
DeleteRange(ctx context.Context, from, to ProjectIndexKey) error
doNotImplement()
}
type ProjectIterator struct {
ormtable.Iterator
}
func (i ProjectIterator) Value() (*Project, error) {
var project Project
err := i.UnmarshalMessage(&project)
return &project, err
}
type ProjectIndexKey interface {
id() uint32
values() []interface{}
projectIndexKey()
}
// primary key starting index..
type ProjectPrimaryKey = ProjectKeyIndexKey
type ProjectKeyIndexKey struct {
vs []interface{}
}
func (x ProjectKeyIndexKey) id() uint32 { return 0 }
func (x ProjectKeyIndexKey) values() []interface{} { return x.vs }
func (x ProjectKeyIndexKey) projectIndexKey() {}
func (this ProjectKeyIndexKey) WithKey(key uint64) ProjectKeyIndexKey {
this.vs = []interface{}{key}
return this
}
type ProjectIdIndexKey struct {
vs []interface{}
}
func (x ProjectIdIndexKey) id() uint32 { return 1 }
func (x ProjectIdIndexKey) values() []interface{} { return x.vs }
func (x ProjectIdIndexKey) projectIndexKey() {}
func (this ProjectIdIndexKey) WithId(id string) ProjectIdIndexKey {
this.vs = []interface{}{id}
return this
}
type ProjectClassKeyIdIndexKey struct {
vs []interface{}
}
func (x ProjectClassKeyIdIndexKey) id() uint32 { return 2 }
func (x ProjectClassKeyIdIndexKey) values() []interface{} { return x.vs }
func (x ProjectClassKeyIdIndexKey) projectIndexKey() {}
func (this ProjectClassKeyIdIndexKey) WithClassKey(class_key uint64) ProjectClassKeyIdIndexKey {
this.vs = []interface{}{class_key}
return this
}
func (this ProjectClassKeyIdIndexKey) WithClassKeyId(class_key uint64, id string) ProjectClassKeyIdIndexKey {
this.vs = []interface{}{class_key, id}
return this
}
type ProjectAdminIndexKey struct {
vs []interface{}
}
func (x ProjectAdminIndexKey) id() uint32 { return 3 }
func (x ProjectAdminIndexKey) values() []interface{} { return x.vs }
func (x ProjectAdminIndexKey) projectIndexKey() {}
func (this ProjectAdminIndexKey) WithAdmin(admin []byte) ProjectAdminIndexKey {
this.vs = []interface{}{admin}
return this
}
type ProjectReferenceIdIndexKey struct {
vs []interface{}
}
func (x ProjectReferenceIdIndexKey) id() uint32 { return 4 }
func (x ProjectReferenceIdIndexKey) values() []interface{} { return x.vs }
func (x ProjectReferenceIdIndexKey) projectIndexKey() {}
func (this ProjectReferenceIdIndexKey) WithReferenceId(reference_id string) ProjectReferenceIdIndexKey {
this.vs = []interface{}{reference_id}
return this
}
type ProjectClassKeyReferenceIdIndexKey struct {
vs []interface{}
}
func (x ProjectClassKeyReferenceIdIndexKey) id() uint32 { return 5 }
func (x ProjectClassKeyReferenceIdIndexKey) values() []interface{} { return x.vs }
func (x ProjectClassKeyReferenceIdIndexKey) projectIndexKey() {}
func (this ProjectClassKeyReferenceIdIndexKey) WithClassKey(class_key uint64) ProjectClassKeyReferenceIdIndexKey {
this.vs = []interface{}{class_key}
return this
}
func (this ProjectClassKeyReferenceIdIndexKey) WithClassKeyReferenceId(class_key uint64, reference_id string) ProjectClassKeyReferenceIdIndexKey {
this.vs = []interface{}{class_key, reference_id}
return this
}
type projectTable struct {
table ormtable.AutoIncrementTable
}
func (this projectTable) Insert(ctx context.Context, project *Project) error {
return this.table.Insert(ctx, project)
}
func (this projectTable) Update(ctx context.Context, project *Project) error {
return this.table.Update(ctx, project)
}
func (this projectTable) Save(ctx context.Context, project *Project) error {
return this.table.Save(ctx, project)
}
func (this projectTable) Delete(ctx context.Context, project *Project) error {
return this.table.Delete(ctx, project)
}
func (this projectTable) InsertReturningID(ctx context.Context, project *Project) (uint64, error) {
return this.table.InsertReturningID(ctx, project)
}
func (this projectTable) Has(ctx context.Context, key uint64) (found bool, err error) {
return this.table.PrimaryKey().Has(ctx, key)
}
func (this projectTable) Get(ctx context.Context, key uint64) (*Project, error) {
var project Project
found, err := this.table.PrimaryKey().Get(ctx, &project, key)
if err != nil {
return nil, err
}
if !found {
return nil, ormerrors.NotFound
}
return &project, nil
}
func (this projectTable) HasById(ctx context.Context, id string) (found bool, err error) {
return this.table.GetIndexByID(1).(ormtable.UniqueIndex).Has(ctx,
id,
)
}
func (this projectTable) GetById(ctx context.Context, id string) (*Project, error) {
var project Project
found, err := this.table.GetIndexByID(1).(ormtable.UniqueIndex).Get(ctx, &project,
id,
)
if err != nil {
return nil, err
}
if !found {
return nil, ormerrors.NotFound
}
return &project, nil
}
func (this projectTable) HasByClassKeyId(ctx context.Context, class_key uint64, id string) (found bool, err error) {
return this.table.GetIndexByID(2).(ormtable.UniqueIndex).Has(ctx,
class_key,
id,
)
}
func (this projectTable) GetByClassKeyId(ctx context.Context, class_key uint64, id string) (*Project, error) {
var project Project
found, err := this.table.GetIndexByID(2).(ormtable.UniqueIndex).Get(ctx, &project,
class_key,
id,
)
if err != nil {
return nil, err
}
if !found {
return nil, ormerrors.NotFound
}
return &project, nil
}
func (this projectTable) List(ctx context.Context, prefixKey ProjectIndexKey, opts ...ormlist.Option) (ProjectIterator, error) {
it, err := this.table.GetIndexByID(prefixKey.id()).List(ctx, prefixKey.values(), opts...)
return ProjectIterator{it}, err
}
func (this projectTable) ListRange(ctx context.Context, from, to ProjectIndexKey, opts ...ormlist.Option) (ProjectIterator, error) {
it, err := this.table.GetIndexByID(from.id()).ListRange(ctx, from.values(), to.values(), opts...)
return ProjectIterator{it}, err
}
func (this projectTable) DeleteBy(ctx context.Context, prefixKey ProjectIndexKey) error {
return this.table.GetIndexByID(prefixKey.id()).DeleteBy(ctx, prefixKey.values()...)
}
func (this projectTable) DeleteRange(ctx context.Context, from, to ProjectIndexKey) error {
return this.table.GetIndexByID(from.id()).DeleteRange(ctx, from.values(), to.values())
}
func (this projectTable) doNotImplement() {}
var _ ProjectTable = projectTable{}
func NewProjectTable(db ormtable.Schema) (ProjectTable, error) {
table := db.GetTable(&Project{})
if table == nil {
return nil, ormerrors.TableNotFound.Wrap(string((&Project{}).ProtoReflect().Descriptor().FullName()))
}
return projectTable{table.(ormtable.AutoIncrementTable)}, nil
}
type BatchTable interface {
Insert(ctx context.Context, batch *Batch) error
InsertReturningID(ctx context.Context, batch *Batch) (uint64, error)
Update(ctx context.Context, batch *Batch) error
Save(ctx context.Context, batch *Batch) error
Delete(ctx context.Context, batch *Batch) error
Has(ctx context.Context, key uint64) (found bool, err error)
// Get returns nil and an error which responds true to ormerrors.IsNotFound() if the record was not found.
Get(ctx context.Context, key uint64) (*Batch, error)
HasByDenom(ctx context.Context, denom string) (found bool, err error)
// GetByDenom returns nil and an error which responds true to ormerrors.IsNotFound() if the record was not found.
GetByDenom(ctx context.Context, denom string) (*Batch, error)
List(ctx context.Context, prefixKey BatchIndexKey, opts ...ormlist.Option) (BatchIterator, error)
ListRange(ctx context.Context, from, to BatchIndexKey, opts ...ormlist.Option) (BatchIterator, error)
DeleteBy(ctx context.Context, prefixKey BatchIndexKey) error
DeleteRange(ctx context.Context, from, to BatchIndexKey) error
doNotImplement()
}
type BatchIterator struct {
ormtable.Iterator
}
func (i BatchIterator) Value() (*Batch, error) {
var batch Batch
err := i.UnmarshalMessage(&batch)
return &batch, err
}
type BatchIndexKey interface {
id() uint32
values() []interface{}
batchIndexKey()
}
// primary key starting index..
type BatchPrimaryKey = BatchKeyIndexKey
type BatchKeyIndexKey struct {
vs []interface{}
}
func (x BatchKeyIndexKey) id() uint32 { return 0 }
func (x BatchKeyIndexKey) values() []interface{} { return x.vs }
func (x BatchKeyIndexKey) batchIndexKey() {}
func (this BatchKeyIndexKey) WithKey(key uint64) BatchKeyIndexKey {
this.vs = []interface{}{key}
return this
}
type BatchDenomIndexKey struct {
vs []interface{}
}
func (x BatchDenomIndexKey) id() uint32 { return 1 }
func (x BatchDenomIndexKey) values() []interface{} { return x.vs }
func (x BatchDenomIndexKey) batchIndexKey() {}
func (this BatchDenomIndexKey) WithDenom(denom string) BatchDenomIndexKey {
this.vs = []interface{}{denom}
return this
}
type BatchProjectKeyIndexKey struct {
vs []interface{}
}
func (x BatchProjectKeyIndexKey) id() uint32 { return 2 }
func (x BatchProjectKeyIndexKey) values() []interface{} { return x.vs }
func (x BatchProjectKeyIndexKey) batchIndexKey() {}
func (this BatchProjectKeyIndexKey) WithProjectKey(project_key uint64) BatchProjectKeyIndexKey {
this.vs = []interface{}{project_key}
return this
}
type BatchStartDateIndexKey struct {
vs []interface{}
}
func (x BatchStartDateIndexKey) id() uint32 { return 3 }
func (x BatchStartDateIndexKey) values() []interface{} { return x.vs }
func (x BatchStartDateIndexKey) batchIndexKey() {}
func (this BatchStartDateIndexKey) WithStartDate(start_date *timestamppb.Timestamp) BatchStartDateIndexKey {
this.vs = []interface{}{start_date}
return this
}
type BatchIssuerIndexKey struct {
vs []interface{}
}
func (x BatchIssuerIndexKey) id() uint32 { return 4 }
func (x BatchIssuerIndexKey) values() []interface{} { return x.vs }
func (x BatchIssuerIndexKey) batchIndexKey() {}
func (this BatchIssuerIndexKey) WithIssuer(issuer []byte) BatchIssuerIndexKey {
this.vs = []interface{}{issuer}
return this
}
type batchTable struct {
table ormtable.AutoIncrementTable
}
func (this batchTable) Insert(ctx context.Context, batch *Batch) error {
return this.table.Insert(ctx, batch)
}
func (this batchTable) Update(ctx context.Context, batch *Batch) error {
return this.table.Update(ctx, batch)
}
func (this batchTable) Save(ctx context.Context, batch *Batch) error {
return this.table.Save(ctx, batch)
}
func (this batchTable) Delete(ctx context.Context, batch *Batch) error {
return this.table.Delete(ctx, batch)
}
func (this batchTable) InsertReturningID(ctx context.Context, batch *Batch) (uint64, error) {
return this.table.InsertReturningID(ctx, batch)
}
func (this batchTable) Has(ctx context.Context, key uint64) (found bool, err error) {
return this.table.PrimaryKey().Has(ctx, key)
}
func (this batchTable) Get(ctx context.Context, key uint64) (*Batch, error) {
var batch Batch
found, err := this.table.PrimaryKey().Get(ctx, &batch, key)
if err != nil {
return nil, err
}
if !found {
return nil, ormerrors.NotFound
}
return &batch, nil
}
func (this batchTable) HasByDenom(ctx context.Context, denom string) (found bool, err error) {
return this.table.GetIndexByID(1).(ormtable.UniqueIndex).Has(ctx,
denom,
)
}
func (this batchTable) GetByDenom(ctx context.Context, denom string) (*Batch, error) {
var batch Batch
found, err := this.table.GetIndexByID(1).(ormtable.UniqueIndex).Get(ctx, &batch,
denom,
)
if err != nil {
return nil, err
}
if !found {
return nil, ormerrors.NotFound
}
return &batch, nil
}
func (this batchTable) List(ctx context.Context, prefixKey BatchIndexKey, opts ...ormlist.Option) (BatchIterator, error) {
it, err := this.table.GetIndexByID(prefixKey.id()).List(ctx, prefixKey.values(), opts...)
return BatchIterator{it}, err
}
func (this batchTable) ListRange(ctx context.Context, from, to BatchIndexKey, opts ...ormlist.Option) (BatchIterator, error) {
it, err := this.table.GetIndexByID(from.id()).ListRange(ctx, from.values(), to.values(), opts...)
return BatchIterator{it}, err
}
func (this batchTable) DeleteBy(ctx context.Context, prefixKey BatchIndexKey) error {
return this.table.GetIndexByID(prefixKey.id()).DeleteBy(ctx, prefixKey.values()...)
}
func (this batchTable) DeleteRange(ctx context.Context, from, to BatchIndexKey) error {
return this.table.GetIndexByID(from.id()).DeleteRange(ctx, from.values(), to.values())
}
func (this batchTable) doNotImplement() {}
var _ BatchTable = batchTable{}
func NewBatchTable(db ormtable.Schema) (BatchTable, error) {
table := db.GetTable(&Batch{})
if table == nil {
return nil, ormerrors.TableNotFound.Wrap(string((&Batch{}).ProtoReflect().Descriptor().FullName()))
}
return batchTable{table.(ormtable.AutoIncrementTable)}, nil
}
type ClassSequenceTable interface {
Insert(ctx context.Context, classSequence *ClassSequence) error
Update(ctx context.Context, classSequence *ClassSequence) error
Save(ctx context.Context, classSequence *ClassSequence) error
Delete(ctx context.Context, classSequence *ClassSequence) error
Has(ctx context.Context, credit_type_abbrev string) (found bool, err error)
// Get returns nil and an error which responds true to ormerrors.IsNotFound() if the record was not found.
Get(ctx context.Context, credit_type_abbrev string) (*ClassSequence, error)
List(ctx context.Context, prefixKey ClassSequenceIndexKey, opts ...ormlist.Option) (ClassSequenceIterator, error)
ListRange(ctx context.Context, from, to ClassSequenceIndexKey, opts ...ormlist.Option) (ClassSequenceIterator, error)
DeleteBy(ctx context.Context, prefixKey ClassSequenceIndexKey) error
DeleteRange(ctx context.Context, from, to ClassSequenceIndexKey) error
doNotImplement()
}
type ClassSequenceIterator struct {
ormtable.Iterator
}
func (i ClassSequenceIterator) Value() (*ClassSequence, error) {
var classSequence ClassSequence
err := i.UnmarshalMessage(&classSequence)
return &classSequence, err
}
type ClassSequenceIndexKey interface {
id() uint32
values() []interface{}
classSequenceIndexKey()
}
// primary key starting index..
type ClassSequencePrimaryKey = ClassSequenceCreditTypeAbbrevIndexKey
type ClassSequenceCreditTypeAbbrevIndexKey struct {
vs []interface{}
}
func (x ClassSequenceCreditTypeAbbrevIndexKey) id() uint32 { return 0 }
func (x ClassSequenceCreditTypeAbbrevIndexKey) values() []interface{} { return x.vs }
func (x ClassSequenceCreditTypeAbbrevIndexKey) classSequenceIndexKey() {}
func (this ClassSequenceCreditTypeAbbrevIndexKey) WithCreditTypeAbbrev(credit_type_abbrev string) ClassSequenceCreditTypeAbbrevIndexKey {
this.vs = []interface{}{credit_type_abbrev}
return this
}
type classSequenceTable struct {
table ormtable.Table
}
func (this classSequenceTable) Insert(ctx context.Context, classSequence *ClassSequence) error {
return this.table.Insert(ctx, classSequence)
}
func (this classSequenceTable) Update(ctx context.Context, classSequence *ClassSequence) error {
return this.table.Update(ctx, classSequence)
}
func (this classSequenceTable) Save(ctx context.Context, classSequence *ClassSequence) error {
return this.table.Save(ctx, classSequence)
}
func (this classSequenceTable) Delete(ctx context.Context, classSequence *ClassSequence) error {
return this.table.Delete(ctx, classSequence)
}
func (this classSequenceTable) Has(ctx context.Context, credit_type_abbrev string) (found bool, err error) {
return this.table.PrimaryKey().Has(ctx, credit_type_abbrev)
}
func (this classSequenceTable) Get(ctx context.Context, credit_type_abbrev string) (*ClassSequence, error) {
var classSequence ClassSequence
found, err := this.table.PrimaryKey().Get(ctx, &classSequence, credit_type_abbrev)
if err != nil {
return nil, err
}
if !found {
return nil, ormerrors.NotFound
}
return &classSequence, nil
}
func (this classSequenceTable) List(ctx context.Context, prefixKey ClassSequenceIndexKey, opts ...ormlist.Option) (ClassSequenceIterator, error) {
it, err := this.table.GetIndexByID(prefixKey.id()).List(ctx, prefixKey.values(), opts...)
return ClassSequenceIterator{it}, err
}
func (this classSequenceTable) ListRange(ctx context.Context, from, to ClassSequenceIndexKey, opts ...ormlist.Option) (ClassSequenceIterator, error) {
it, err := this.table.GetIndexByID(from.id()).ListRange(ctx, from.values(), to.values(), opts...)
return ClassSequenceIterator{it}, err
}
func (this classSequenceTable) DeleteBy(ctx context.Context, prefixKey ClassSequenceIndexKey) error {
return this.table.GetIndexByID(prefixKey.id()).DeleteBy(ctx, prefixKey.values()...)
}
func (this classSequenceTable) DeleteRange(ctx context.Context, from, to ClassSequenceIndexKey) error {
return this.table.GetIndexByID(from.id()).DeleteRange(ctx, from.values(), to.values())
}