Documentation ¶
Index ¶
- type AlbumsKey
- type AlbumsRow
- func (*AlbumsRow) ColumnExprs() []spansql.Expr
- func (*AlbumsRow) ColumnIDs() []spansql.ID
- func (*AlbumsRow) ColumnNames() []string
- func (r *AlbumsRow) Key() AlbumsKey
- func (r *AlbumsRow) Mutate() (string, []string, []interface{})
- func (r *AlbumsRow) MutateColumns(columns []string) (string, []string, []interface{})
- func (r *AlbumsRow) MutatePresentColumns() (string, []string, []interface{})
- func (r *AlbumsRow) UnmarshalSpannerRow(row *spanner.Row) error
- func (r *AlbumsRow) Validate() error
- type AlbumsRowIterator
- type AlbumsTableDescriptor
- type BatchGetAlbumsRowsQuery
- type BatchGetSingersRowsQuery
- type BatchGetSongsRowsQuery
- type ColumnDescriptor
- type DatabaseDescriptor
- type GetAlbumsRowQuery
- type GetSingersRowQuery
- type GetSongsRowQuery
- type ListAlbumsRowsQuery
- type ListSingersRowsQuery
- type ListSongsRowsQuery
- type ReadTransaction
- func (t ReadTransaction) BatchGetAlbumsRows(ctx context.Context, query BatchGetAlbumsRowsQuery) (map[AlbumsKey]*AlbumsRow, error)
- func (t ReadTransaction) BatchGetSingersRows(ctx context.Context, query BatchGetSingersRowsQuery) (map[SingersKey]*SingersRow, error)
- func (t ReadTransaction) BatchGetSongsRows(ctx context.Context, query BatchGetSongsRowsQuery) (map[SongsKey]*SongsRow, error)
- func (t ReadTransaction) GetAlbumsRow(ctx context.Context, query GetAlbumsRowQuery) (*AlbumsRow, error)
- func (t ReadTransaction) GetSingersRow(ctx context.Context, query GetSingersRowQuery) (*SingersRow, error)
- func (t ReadTransaction) GetSongsRow(ctx context.Context, query GetSongsRowQuery) (*SongsRow, error)
- func (t ReadTransaction) ListAlbumsRows(ctx context.Context, query ListAlbumsRowsQuery) AlbumsRowIterator
- func (t ReadTransaction) ListSingersRows(ctx context.Context, query ListSingersRowsQuery) SingersRowIterator
- func (t ReadTransaction) ListSongsRows(ctx context.Context, query ListSongsRowsQuery) SongsRowIterator
- func (t ReadTransaction) ReadAlbumsRows(ctx context.Context, keySet spanner.KeySet) AlbumsRowIterator
- func (t ReadTransaction) ReadSingersRows(ctx context.Context, keySet spanner.KeySet) SingersRowIterator
- func (t ReadTransaction) ReadSongsRows(ctx context.Context, keySet spanner.KeySet) SongsRowIterator
- type SingersKey
- type SingersRow
- func (*SingersRow) ColumnExprs() []spansql.Expr
- func (*SingersRow) ColumnIDs() []spansql.ID
- func (*SingersRow) ColumnNames() []string
- func (r *SingersRow) Key() SingersKey
- func (r *SingersRow) Mutate() (string, []string, []interface{})
- func (r *SingersRow) MutateColumns(columns []string) (string, []string, []interface{})
- func (r *SingersRow) MutatePresentColumns() (string, []string, []interface{})
- func (r *SingersRow) UnmarshalSpannerRow(row *spanner.Row) error
- func (r *SingersRow) Validate() error
- type SingersRowIterator
- type SingersTableDescriptor
- type SongsKey
- type SongsRow
- func (*SongsRow) ColumnExprs() []spansql.Expr
- func (*SongsRow) ColumnIDs() []spansql.ID
- func (*SongsRow) ColumnNames() []string
- func (r *SongsRow) Key() SongsKey
- func (r *SongsRow) Mutate() (string, []string, []interface{})
- func (r *SongsRow) MutateColumns(columns []string) (string, []string, []interface{})
- func (r *SongsRow) MutatePresentColumns() (string, []string, []interface{})
- func (r *SongsRow) UnmarshalSpannerRow(row *spanner.Row) error
- func (r *SongsRow) Validate() error
- type SongsRowIterator
- type SongsTableDescriptor
- type SpannerReadTransaction
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AlbumsRow ¶
type AlbumsRow struct { SingerId int64 `spanner:"SingerId"` AlbumId int64 `spanner:"AlbumId"` AlbumTitle spanner.NullString `spanner:"AlbumTitle"` Songs []*SongsRow `spanner:"Songs"` }
func (*AlbumsRow) ColumnExprs ¶
func (*AlbumsRow) ColumnNames ¶
func (*AlbumsRow) MutateColumns ¶ added in v0.15.0
func (*AlbumsRow) MutatePresentColumns ¶ added in v0.31.0
func (*AlbumsRow) UnmarshalSpannerRow ¶
type AlbumsRowIterator ¶
type AlbumsTableDescriptor ¶
type AlbumsTableDescriptor interface { TableName() string TableID() spansql.ID ColumnNames() []string ColumnIDs() []spansql.ID ColumnExprs() []spansql.Expr SingerId() ColumnDescriptor AlbumId() ColumnDescriptor AlbumTitle() ColumnDescriptor }
type BatchGetAlbumsRowsQuery ¶ added in v0.16.0
type BatchGetSingersRowsQuery ¶ added in v0.16.0
type BatchGetSingersRowsQuery struct { Keys []SingersKey Albums bool Songs bool }
type BatchGetSongsRowsQuery ¶ added in v0.16.0
type BatchGetSongsRowsQuery struct {
Keys []SongsKey
}
type ColumnDescriptor ¶
type DatabaseDescriptor ¶
type DatabaseDescriptor interface { Singers() SingersTableDescriptor Albums() AlbumsTableDescriptor Songs() SongsTableDescriptor }
func Descriptor ¶
func Descriptor() DatabaseDescriptor
type GetAlbumsRowQuery ¶ added in v0.16.0
type GetSingersRowQuery ¶ added in v0.16.0
type GetSingersRowQuery struct { Key SingersKey Albums bool Songs bool }
type GetSongsRowQuery ¶ added in v0.16.0
type GetSongsRowQuery struct {
Key SongsKey
}
type ListAlbumsRowsQuery ¶ added in v0.16.0
type ListSingersRowsQuery ¶ added in v0.16.0
type ListSongsRowsQuery ¶ added in v0.16.0
type ReadTransaction ¶ added in v0.15.0
type ReadTransaction struct {
Tx SpannerReadTransaction
}
func Query ¶ added in v0.15.0
func Query(tx SpannerReadTransaction) ReadTransaction
Example (Get) ¶
package main import ( "context" "cloud.google.com/go/spanner" "go.einride.tech/spanner-aip/internal/examples/musicdb" ) func main() { ctx := context.Background() client, err := spanner.NewClient( ctx, "projects/<PROJECT>/instances/<INSTANCE>/databases/<DATABASE>", ) if err != nil { panic(err) // TODO: Handle error. } singer, err := musicdb.Query(client.Single()).GetSingersRow(ctx, musicdb.GetSingersRowQuery{ Key: musicdb.SingersKey{SingerId: 42}, }) if err != nil { panic(err) // TODO: Handle error. } _ = singer // TODO: Use singer. }
Output:
Example (GetMultiple) ¶
package main import ( "context" "cloud.google.com/go/spanner" "go.einride.tech/spanner-aip/internal/examples/musicdb" ) func main() { ctx := context.Background() client, err := spanner.NewClient( ctx, "projects/<PROJECT>/instances/<INSTANCE>/databases/<DATABASE>", ) if err != nil { panic(err) // TODO: Handle error. } tx := client.ReadOnlyTransaction() defer tx.Close() singer, err := musicdb.Query(tx).GetSingersRow(ctx, musicdb.GetSingersRowQuery{ Key: musicdb.SingersKey{SingerId: 42}, }) if err != nil { panic(err) // TODO: Handle error. } album, err := musicdb.Query(tx).GetAlbumsRow(ctx, musicdb.GetAlbumsRowQuery{ Key: musicdb.AlbumsKey{SingerId: 42, AlbumId: 24}, }) if err != nil { panic(err) // TODO: Handle error. } _ = singer // TODO: Use singer. _ = album // TODO: Use album. }
Output:
Example (List) ¶
package main import ( "context" "cloud.google.com/go/spanner" "cloud.google.com/go/spanner/spansql" "go.einride.tech/spanner-aip/internal/examples/musicdb" ) func main() { ctx := context.Background() client, err := spanner.NewClient( ctx, "projects/<PROJECT>/instances/<INSTANCE>/databases/<DATABASE>", ) if err != nil { panic(err) // TODO: Handle error. } // SELECT * FROM Singers // WHERE LastName = "Sinatra" // ORDER BY FirstName DESC // LIMIT 5 // OFFSET 10 if err := musicdb.Query(client.Single()).ListSingersRows(ctx, musicdb.ListSingersRowsQuery{ Where: spansql.ComparisonOp{ Op: spansql.Eq, LHS: musicdb.Descriptor().Singers().LastName().ColumnID(), RHS: spansql.StringLiteral("Sinatra"), }, Order: []spansql.Order{ {Expr: musicdb.Descriptor().Singers().FirstName().ColumnID(), Desc: true}, }, Limit: 5, Offset: 10, }).Do(func(singer *musicdb.SingersRow) error { _ = singer // TODO: Use singer. return nil }); err != nil { panic(err) // TODO: Handle error. } }
Output:
func (ReadTransaction) BatchGetAlbumsRows ¶ added in v0.15.0
func (t ReadTransaction) BatchGetAlbumsRows( ctx context.Context, query BatchGetAlbumsRowsQuery, ) (map[AlbumsKey]*AlbumsRow, error)
func (ReadTransaction) BatchGetSingersRows ¶ added in v0.15.0
func (t ReadTransaction) BatchGetSingersRows( ctx context.Context, query BatchGetSingersRowsQuery, ) (map[SingersKey]*SingersRow, error)
func (ReadTransaction) BatchGetSongsRows ¶ added in v0.15.0
func (t ReadTransaction) BatchGetSongsRows( ctx context.Context, query BatchGetSongsRowsQuery, ) (map[SongsKey]*SongsRow, error)
func (ReadTransaction) GetAlbumsRow ¶ added in v0.15.0
func (t ReadTransaction) GetAlbumsRow( ctx context.Context, query GetAlbumsRowQuery, ) (*AlbumsRow, error)
func (ReadTransaction) GetSingersRow ¶ added in v0.15.0
func (t ReadTransaction) GetSingersRow( ctx context.Context, query GetSingersRowQuery, ) (*SingersRow, error)
func (ReadTransaction) GetSongsRow ¶ added in v0.15.0
func (t ReadTransaction) GetSongsRow( ctx context.Context, query GetSongsRowQuery, ) (*SongsRow, error)
func (ReadTransaction) ListAlbumsRows ¶ added in v0.15.0
func (t ReadTransaction) ListAlbumsRows( ctx context.Context, query ListAlbumsRowsQuery, ) AlbumsRowIterator
func (ReadTransaction) ListSingersRows ¶ added in v0.15.0
func (t ReadTransaction) ListSingersRows( ctx context.Context, query ListSingersRowsQuery, ) SingersRowIterator
func (ReadTransaction) ListSongsRows ¶ added in v0.15.0
func (t ReadTransaction) ListSongsRows( ctx context.Context, query ListSongsRowsQuery, ) SongsRowIterator
func (ReadTransaction) ReadAlbumsRows ¶ added in v0.15.0
func (t ReadTransaction) ReadAlbumsRows( ctx context.Context, keySet spanner.KeySet, ) AlbumsRowIterator
func (ReadTransaction) ReadSingersRows ¶ added in v0.15.0
func (t ReadTransaction) ReadSingersRows( ctx context.Context, keySet spanner.KeySet, ) SingersRowIterator
func (ReadTransaction) ReadSongsRows ¶ added in v0.15.0
func (t ReadTransaction) ReadSongsRows( ctx context.Context, keySet spanner.KeySet, ) SongsRowIterator
type SingersKey ¶
type SingersKey struct {
SingerId int64
}
func (SingersKey) BoolExpr ¶
func (k SingersKey) BoolExpr() spansql.BoolExpr
func (SingersKey) Delete ¶
func (k SingersKey) Delete() *spanner.Mutation
func (SingersKey) Order ¶
func (SingersKey) Order() []spansql.Order
func (SingersKey) SpannerKey ¶
func (k SingersKey) SpannerKey() spanner.Key
func (SingersKey) SpannerKeySet ¶
func (k SingersKey) SpannerKeySet() spanner.KeySet
type SingersRow ¶
type SingersRow struct { SingerId int64 `spanner:"SingerId"` FirstName spanner.NullString `spanner:"FirstName"` LastName spanner.NullString `spanner:"LastName"` SingerInfo []uint8 `spanner:"SingerInfo"` Albums []*AlbumsRow `spanner:"Albums"` }
func (*SingersRow) ColumnExprs ¶
func (*SingersRow) ColumnExprs() []spansql.Expr
func (*SingersRow) ColumnIDs ¶
func (*SingersRow) ColumnIDs() []spansql.ID
func (*SingersRow) ColumnNames ¶
func (*SingersRow) ColumnNames() []string
func (*SingersRow) Key ¶
func (r *SingersRow) Key() SingersKey
func (*SingersRow) Mutate ¶ added in v0.15.0
func (r *SingersRow) Mutate() (string, []string, []interface{})
func (*SingersRow) MutateColumns ¶ added in v0.15.0
func (r *SingersRow) MutateColumns(columns []string) (string, []string, []interface{})
func (*SingersRow) MutatePresentColumns ¶ added in v0.31.0
func (r *SingersRow) MutatePresentColumns() (string, []string, []interface{})
func (*SingersRow) UnmarshalSpannerRow ¶
func (r *SingersRow) UnmarshalSpannerRow(row *spanner.Row) error
func (*SingersRow) Validate ¶
func (r *SingersRow) Validate() error
type SingersRowIterator ¶
type SingersRowIterator interface { Next() (*SingersRow, error) Do(f func(row *SingersRow) error) error Stop() }
type SingersTableDescriptor ¶
type SingersTableDescriptor interface { TableName() string TableID() spansql.ID ColumnNames() []string ColumnIDs() []spansql.ID ColumnExprs() []spansql.Expr SingerId() ColumnDescriptor FirstName() ColumnDescriptor LastName() ColumnDescriptor SingerInfo() ColumnDescriptor }
type SongsRow ¶
type SongsRow struct { SingerId int64 `spanner:"SingerId"` AlbumId int64 `spanner:"AlbumId"` TrackId int64 `spanner:"TrackId"` SongName spanner.NullString `spanner:"SongName"` }
func (*SongsRow) ColumnExprs ¶
func (*SongsRow) ColumnNames ¶
func (*SongsRow) MutateColumns ¶ added in v0.15.0
func (*SongsRow) MutatePresentColumns ¶ added in v0.31.0
func (*SongsRow) UnmarshalSpannerRow ¶
type SongsRowIterator ¶
type SongsTableDescriptor ¶
type SongsTableDescriptor interface { TableName() string TableID() spansql.ID ColumnNames() []string ColumnIDs() []spansql.ID ColumnExprs() []spansql.Expr SingerId() ColumnDescriptor AlbumId() ColumnDescriptor TrackId() ColumnDescriptor SongName() ColumnDescriptor }
type SpannerReadTransaction ¶
type SpannerReadTransaction interface { Read(ctx context.Context, table string, keys spanner.KeySet, columns []string) *spanner.RowIterator ReadRow(ctx context.Context, table string, key spanner.Key, columns []string) (*spanner.Row, error) Query(ctx context.Context, statement spanner.Statement) *spanner.RowIterator }
Click to show internal directories.
Click to hide internal directories.