cosmos-sdk/orm/internal/testpb/test_schema.cosmos_orm.go

453 lines
16 KiB
Go

// Code generated by protoc-gen-go-cosmos-orm. DO NOT EDIT.
package testpb
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"
)
type ExampleTableTable interface {
Insert(ctx context.Context, exampleTable *ExampleTable) error
Update(ctx context.Context, exampleTable *ExampleTable) error
Save(ctx context.Context, exampleTable *ExampleTable) error
Delete(ctx context.Context, exampleTable *ExampleTable) error
Has(ctx context.Context, u32 uint32, i64 int64, str 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, u32 uint32, i64 int64, str string) (*ExampleTable, error)
HasByU64Str(ctx context.Context, u64 uint64, str string) (found bool, err error)
// GetByU64Str returns nil and an error which responds true to ormerrors.IsNotFound() if the record was not found.
GetByU64Str(ctx context.Context, u64 uint64, str string) (*ExampleTable, error)
List(ctx context.Context, prefixKey ExampleTableIndexKey, opts ...ormlist.Option) (ExampleTableIterator, error)
ListRange(ctx context.Context, from, to ExampleTableIndexKey, opts ...ormlist.Option) (ExampleTableIterator, error)
DeleteBy(ctx context.Context, prefixKey ExampleTableIndexKey) error
DeleteRange(ctx context.Context, from, to ExampleTableIndexKey) error
doNotImplement()
}
type ExampleTableIterator struct {
ormtable.Iterator
}
func (i ExampleTableIterator) Value() (*ExampleTable, error) {
var exampleTable ExampleTable
err := i.UnmarshalMessage(&exampleTable)
return &exampleTable, err
}
type ExampleTableIndexKey interface {
id() uint32
values() []interface{}
exampleTableIndexKey()
}
// primary key starting index..
type ExampleTablePrimaryKey = ExampleTableU32I64StrIndexKey
type ExampleTableU32I64StrIndexKey struct {
vs []interface{}
}
func (x ExampleTableU32I64StrIndexKey) id() uint32 { return 0 }
func (x ExampleTableU32I64StrIndexKey) values() []interface{} { return x.vs }
func (x ExampleTableU32I64StrIndexKey) exampleTableIndexKey() {}
func (this ExampleTableU32I64StrIndexKey) WithU32(u32 uint32) ExampleTableU32I64StrIndexKey {
this.vs = []interface{}{u32}
return this
}
func (this ExampleTableU32I64StrIndexKey) WithU32I64(u32 uint32, i64 int64) ExampleTableU32I64StrIndexKey {
this.vs = []interface{}{u32, i64}
return this
}
func (this ExampleTableU32I64StrIndexKey) WithU32I64Str(u32 uint32, i64 int64, str string) ExampleTableU32I64StrIndexKey {
this.vs = []interface{}{u32, i64, str}
return this
}
type ExampleTableU64StrIndexKey struct {
vs []interface{}
}
func (x ExampleTableU64StrIndexKey) id() uint32 { return 1 }
func (x ExampleTableU64StrIndexKey) values() []interface{} { return x.vs }
func (x ExampleTableU64StrIndexKey) exampleTableIndexKey() {}
func (this ExampleTableU64StrIndexKey) WithU64(u64 uint64) ExampleTableU64StrIndexKey {
this.vs = []interface{}{u64}
return this
}
func (this ExampleTableU64StrIndexKey) WithU64Str(u64 uint64, str string) ExampleTableU64StrIndexKey {
this.vs = []interface{}{u64, str}
return this
}
type ExampleTableStrU32IndexKey struct {
vs []interface{}
}
func (x ExampleTableStrU32IndexKey) id() uint32 { return 2 }
func (x ExampleTableStrU32IndexKey) values() []interface{} { return x.vs }
func (x ExampleTableStrU32IndexKey) exampleTableIndexKey() {}
func (this ExampleTableStrU32IndexKey) WithStr(str string) ExampleTableStrU32IndexKey {
this.vs = []interface{}{str}
return this
}
func (this ExampleTableStrU32IndexKey) WithStrU32(str string, u32 uint32) ExampleTableStrU32IndexKey {
this.vs = []interface{}{str, u32}
return this
}
type ExampleTableBzStrIndexKey struct {
vs []interface{}
}
func (x ExampleTableBzStrIndexKey) id() uint32 { return 3 }
func (x ExampleTableBzStrIndexKey) values() []interface{} { return x.vs }
func (x ExampleTableBzStrIndexKey) exampleTableIndexKey() {}
func (this ExampleTableBzStrIndexKey) WithBz(bz []byte) ExampleTableBzStrIndexKey {
this.vs = []interface{}{bz}
return this
}
func (this ExampleTableBzStrIndexKey) WithBzStr(bz []byte, str string) ExampleTableBzStrIndexKey {
this.vs = []interface{}{bz, str}
return this
}
type exampleTableTable struct {
table ormtable.Table
}
func (this exampleTableTable) Insert(ctx context.Context, exampleTable *ExampleTable) error {
return this.table.Insert(ctx, exampleTable)
}
func (this exampleTableTable) Update(ctx context.Context, exampleTable *ExampleTable) error {
return this.table.Update(ctx, exampleTable)
}
func (this exampleTableTable) Save(ctx context.Context, exampleTable *ExampleTable) error {
return this.table.Save(ctx, exampleTable)
}
func (this exampleTableTable) Delete(ctx context.Context, exampleTable *ExampleTable) error {
return this.table.Delete(ctx, exampleTable)
}
func (this exampleTableTable) Has(ctx context.Context, u32 uint32, i64 int64, str string) (found bool, err error) {
return this.table.PrimaryKey().Has(ctx, u32, i64, str)
}
func (this exampleTableTable) Get(ctx context.Context, u32 uint32, i64 int64, str string) (*ExampleTable, error) {
var exampleTable ExampleTable
found, err := this.table.PrimaryKey().Get(ctx, &exampleTable, u32, i64, str)
if err != nil {
return nil, err
}
if !found {
return nil, ormerrors.NotFound
}
return &exampleTable, nil
}
func (this exampleTableTable) HasByU64Str(ctx context.Context, u64 uint64, str string) (found bool, err error) {
return this.table.GetIndexByID(1).(ormtable.UniqueIndex).Has(ctx,
u64,
str,
)
}
func (this exampleTableTable) GetByU64Str(ctx context.Context, u64 uint64, str string) (*ExampleTable, error) {
var exampleTable ExampleTable
found, err := this.table.GetIndexByID(1).(ormtable.UniqueIndex).Get(ctx, &exampleTable,
u64,
str,
)
if err != nil {
return nil, err
}
if !found {
return nil, ormerrors.NotFound
}
return &exampleTable, nil
}
func (this exampleTableTable) List(ctx context.Context, prefixKey ExampleTableIndexKey, opts ...ormlist.Option) (ExampleTableIterator, error) {
it, err := this.table.GetIndexByID(prefixKey.id()).List(ctx, prefixKey.values(), opts...)
return ExampleTableIterator{it}, err
}
func (this exampleTableTable) ListRange(ctx context.Context, from, to ExampleTableIndexKey, opts ...ormlist.Option) (ExampleTableIterator, error) {
it, err := this.table.GetIndexByID(from.id()).ListRange(ctx, from.values(), to.values(), opts...)
return ExampleTableIterator{it}, err
}
func (this exampleTableTable) DeleteBy(ctx context.Context, prefixKey ExampleTableIndexKey) error {
return this.table.GetIndexByID(prefixKey.id()).DeleteBy(ctx, prefixKey.values()...)
}
func (this exampleTableTable) DeleteRange(ctx context.Context, from, to ExampleTableIndexKey) error {
return this.table.GetIndexByID(from.id()).DeleteRange(ctx, from.values(), to.values())
}
func (this exampleTableTable) doNotImplement() {}
var _ ExampleTableTable = exampleTableTable{}
func NewExampleTableTable(db ormtable.Schema) (ExampleTableTable, error) {
table := db.GetTable(&ExampleTable{})
if table == nil {
return nil, ormerrors.TableNotFound.Wrap(string((&ExampleTable{}).ProtoReflect().Descriptor().FullName()))
}
return exampleTableTable{table}, nil
}
type ExampleAutoIncrementTableTable interface {
Insert(ctx context.Context, exampleAutoIncrementTable *ExampleAutoIncrementTable) error
InsertReturningID(ctx context.Context, exampleAutoIncrementTable *ExampleAutoIncrementTable) (uint64, error)
Update(ctx context.Context, exampleAutoIncrementTable *ExampleAutoIncrementTable) error
Save(ctx context.Context, exampleAutoIncrementTable *ExampleAutoIncrementTable) error
Delete(ctx context.Context, exampleAutoIncrementTable *ExampleAutoIncrementTable) error
Has(ctx context.Context, id 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, id uint64) (*ExampleAutoIncrementTable, error)
HasByX(ctx context.Context, x string) (found bool, err error)
// GetByX returns nil and an error which responds true to ormerrors.IsNotFound() if the record was not found.
GetByX(ctx context.Context, x string) (*ExampleAutoIncrementTable, error)
List(ctx context.Context, prefixKey ExampleAutoIncrementTableIndexKey, opts ...ormlist.Option) (ExampleAutoIncrementTableIterator, error)
ListRange(ctx context.Context, from, to ExampleAutoIncrementTableIndexKey, opts ...ormlist.Option) (ExampleAutoIncrementTableIterator, error)
DeleteBy(ctx context.Context, prefixKey ExampleAutoIncrementTableIndexKey) error
DeleteRange(ctx context.Context, from, to ExampleAutoIncrementTableIndexKey) error
doNotImplement()
}
type ExampleAutoIncrementTableIterator struct {
ormtable.Iterator
}
func (i ExampleAutoIncrementTableIterator) Value() (*ExampleAutoIncrementTable, error) {
var exampleAutoIncrementTable ExampleAutoIncrementTable
err := i.UnmarshalMessage(&exampleAutoIncrementTable)
return &exampleAutoIncrementTable, err
}
type ExampleAutoIncrementTableIndexKey interface {
id() uint32
values() []interface{}
exampleAutoIncrementTableIndexKey()
}
// primary key starting index..
type ExampleAutoIncrementTablePrimaryKey = ExampleAutoIncrementTableIdIndexKey
type ExampleAutoIncrementTableIdIndexKey struct {
vs []interface{}
}
func (x ExampleAutoIncrementTableIdIndexKey) id() uint32 { return 0 }
func (x ExampleAutoIncrementTableIdIndexKey) values() []interface{} { return x.vs }
func (x ExampleAutoIncrementTableIdIndexKey) exampleAutoIncrementTableIndexKey() {}
func (this ExampleAutoIncrementTableIdIndexKey) WithId(id uint64) ExampleAutoIncrementTableIdIndexKey {
this.vs = []interface{}{id}
return this
}
type ExampleAutoIncrementTableXIndexKey struct {
vs []interface{}
}
func (x ExampleAutoIncrementTableXIndexKey) id() uint32 { return 1 }
func (x ExampleAutoIncrementTableXIndexKey) values() []interface{} { return x.vs }
func (x ExampleAutoIncrementTableXIndexKey) exampleAutoIncrementTableIndexKey() {}
func (this ExampleAutoIncrementTableXIndexKey) WithX(x string) ExampleAutoIncrementTableXIndexKey {
this.vs = []interface{}{x}
return this
}
type exampleAutoIncrementTableTable struct {
table ormtable.AutoIncrementTable
}
func (this exampleAutoIncrementTableTable) Insert(ctx context.Context, exampleAutoIncrementTable *ExampleAutoIncrementTable) error {
return this.table.Insert(ctx, exampleAutoIncrementTable)
}
func (this exampleAutoIncrementTableTable) Update(ctx context.Context, exampleAutoIncrementTable *ExampleAutoIncrementTable) error {
return this.table.Update(ctx, exampleAutoIncrementTable)
}
func (this exampleAutoIncrementTableTable) Save(ctx context.Context, exampleAutoIncrementTable *ExampleAutoIncrementTable) error {
return this.table.Save(ctx, exampleAutoIncrementTable)
}
func (this exampleAutoIncrementTableTable) Delete(ctx context.Context, exampleAutoIncrementTable *ExampleAutoIncrementTable) error {
return this.table.Delete(ctx, exampleAutoIncrementTable)
}
func (this exampleAutoIncrementTableTable) InsertReturningID(ctx context.Context, exampleAutoIncrementTable *ExampleAutoIncrementTable) (uint64, error) {
return this.table.InsertReturningID(ctx, exampleAutoIncrementTable)
}
func (this exampleAutoIncrementTableTable) Has(ctx context.Context, id uint64) (found bool, err error) {
return this.table.PrimaryKey().Has(ctx, id)
}
func (this exampleAutoIncrementTableTable) Get(ctx context.Context, id uint64) (*ExampleAutoIncrementTable, error) {
var exampleAutoIncrementTable ExampleAutoIncrementTable
found, err := this.table.PrimaryKey().Get(ctx, &exampleAutoIncrementTable, id)
if err != nil {
return nil, err
}
if !found {
return nil, ormerrors.NotFound
}
return &exampleAutoIncrementTable, nil
}
func (this exampleAutoIncrementTableTable) HasByX(ctx context.Context, x string) (found bool, err error) {
return this.table.GetIndexByID(1).(ormtable.UniqueIndex).Has(ctx,
x,
)
}
func (this exampleAutoIncrementTableTable) GetByX(ctx context.Context, x string) (*ExampleAutoIncrementTable, error) {
var exampleAutoIncrementTable ExampleAutoIncrementTable
found, err := this.table.GetIndexByID(1).(ormtable.UniqueIndex).Get(ctx, &exampleAutoIncrementTable,
x,
)
if err != nil {
return nil, err
}
if !found {
return nil, ormerrors.NotFound
}
return &exampleAutoIncrementTable, nil
}
func (this exampleAutoIncrementTableTable) List(ctx context.Context, prefixKey ExampleAutoIncrementTableIndexKey, opts ...ormlist.Option) (ExampleAutoIncrementTableIterator, error) {
it, err := this.table.GetIndexByID(prefixKey.id()).List(ctx, prefixKey.values(), opts...)
return ExampleAutoIncrementTableIterator{it}, err
}
func (this exampleAutoIncrementTableTable) ListRange(ctx context.Context, from, to ExampleAutoIncrementTableIndexKey, opts ...ormlist.Option) (ExampleAutoIncrementTableIterator, error) {
it, err := this.table.GetIndexByID(from.id()).ListRange(ctx, from.values(), to.values(), opts...)
return ExampleAutoIncrementTableIterator{it}, err
}
func (this exampleAutoIncrementTableTable) DeleteBy(ctx context.Context, prefixKey ExampleAutoIncrementTableIndexKey) error {
return this.table.GetIndexByID(prefixKey.id()).DeleteBy(ctx, prefixKey.values()...)
}
func (this exampleAutoIncrementTableTable) DeleteRange(ctx context.Context, from, to ExampleAutoIncrementTableIndexKey) error {
return this.table.GetIndexByID(from.id()).DeleteRange(ctx, from.values(), to.values())
}
func (this exampleAutoIncrementTableTable) doNotImplement() {}
var _ ExampleAutoIncrementTableTable = exampleAutoIncrementTableTable{}
func NewExampleAutoIncrementTableTable(db ormtable.Schema) (ExampleAutoIncrementTableTable, error) {
table := db.GetTable(&ExampleAutoIncrementTable{})
if table == nil {
return nil, ormerrors.TableNotFound.Wrap(string((&ExampleAutoIncrementTable{}).ProtoReflect().Descriptor().FullName()))
}
return exampleAutoIncrementTableTable{table.(ormtable.AutoIncrementTable)}, nil
}
// singleton store
type ExampleSingletonTable interface {
Get(ctx context.Context) (*ExampleSingleton, error)
Save(ctx context.Context, exampleSingleton *ExampleSingleton) error
}
type exampleSingletonTable struct {
table ormtable.Table
}
var _ ExampleSingletonTable = exampleSingletonTable{}
func (x exampleSingletonTable) Get(ctx context.Context) (*ExampleSingleton, error) {
exampleSingleton := &ExampleSingleton{}
_, err := x.table.Get(ctx, exampleSingleton)
return exampleSingleton, err
}
func (x exampleSingletonTable) Save(ctx context.Context, exampleSingleton *ExampleSingleton) error {
return x.table.Save(ctx, exampleSingleton)
}
func NewExampleSingletonTable(db ormtable.Schema) (ExampleSingletonTable, error) {
table := db.GetTable(&ExampleSingleton{})
if table == nil {
return nil, ormerrors.TableNotFound.Wrap(string((&ExampleSingleton{}).ProtoReflect().Descriptor().FullName()))
}
return &exampleSingletonTable{table}, nil
}
type TestSchemaStore interface {
ExampleTableTable() ExampleTableTable
ExampleAutoIncrementTableTable() ExampleAutoIncrementTableTable
ExampleSingletonTable() ExampleSingletonTable
doNotImplement()
}
type testSchemaStore struct {
exampleTable ExampleTableTable
exampleAutoIncrementTable ExampleAutoIncrementTableTable
exampleSingleton ExampleSingletonTable
}
func (x testSchemaStore) ExampleTableTable() ExampleTableTable {
return x.exampleTable
}
func (x testSchemaStore) ExampleAutoIncrementTableTable() ExampleAutoIncrementTableTable {
return x.exampleAutoIncrementTable
}
func (x testSchemaStore) ExampleSingletonTable() ExampleSingletonTable {
return x.exampleSingleton
}
func (testSchemaStore) doNotImplement() {}
var _ TestSchemaStore = testSchemaStore{}
func NewTestSchemaStore(db ormtable.Schema) (TestSchemaStore, error) {
exampleTableTable, err := NewExampleTableTable(db)
if err != nil {
return nil, err
}
exampleAutoIncrementTableTable, err := NewExampleAutoIncrementTableTable(db)
if err != nil {
return nil, err
}
exampleSingletonTable, err := NewExampleSingletonTable(db)
if err != nil {
return nil, err
}
return testSchemaStore{
exampleTableTable,
exampleAutoIncrementTableTable,
exampleSingletonTable,
}, nil
}