Documentation ¶
Index ¶
- func GetDBPath(projectID, instanceName, dbName string) string
- func GetOneWithIterator(iter *spanner.RowIterator) (row *spanner.Row, exist bool, err error)
- func IterToStruct[T any](iter *spanner.RowIterator) (result T, exist bool, err error)
- func IterToStructs[T any](iter *spanner.RowIterator) ([]T, error)
- func ToSpannerKey(args ...interface{}) spanner.Key
- type NullTime
- type Time
- type Tx
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetDBPath ¶
GetDBPath is a simple function that returns the database path to use as argument for spanner.NewClients
func GetOneWithIterator ¶
GetOneWithIterator is a helper function to get one row from a row iterator You can use it to simplify your code when you know there is only one row in the iterator.
func IterToStruct ¶
func IterToStruct[T any](iter *spanner.RowIterator) (result T, exist bool, err error)
IterToStruct is a helper function to process and convert one row from a row iterator You can use it to simplify your code when you know there is only one row in the iterator.
func IterToStructs ¶
func IterToStructs[T any](iter *spanner.RowIterator) ([]T, error)
IterToStructs is a helper function to process a row iterator and convert each row to a struct This function will return an array of structs and/or the spanner error if one occurs.
func ToSpannerKey ¶
ToSpannerKey wrap given arguments and return a spanner.Key
Types ¶
type NullTime ¶ added in v0.0.5
NullTime overrides the spanner.NullTime to produce a unix milli timestamp when marshalled to json
func NullCommitTimestamp ¶ added in v0.0.5
func NullCommitTimestamp() NullTime
NullCommitTimestamp returns a spanner.CommitTimestamp casted to a models.NullTime
func (NullTime) MarshalJSON ¶ added in v0.0.5
MarshalJSON implements the json.Marshaler interface to produce a unix milli timestamp
func (*NullTime) UnmarshalJSON ¶ added in v0.0.5
UnmarshalJSON implements the json.Unmarshaler interface to handle a unix milli timestamp and convert it to a NullTime
type Time ¶ added in v0.0.5
Time overrides the spanner.Time to produce a unix milli timestamp when marshalled to json
func CommitTimestamp ¶ added in v0.0.5
func CommitTimestamp() Time
CommitTimestamp returns a spanner.CommitTimestamp cast to a models.Time
func (Time) MarshalJSON ¶ added in v0.0.5
MarshalJSON implements the json.Marshaler interface to produce a unix milli timestamp
func (*Time) UnmarshalJSON ¶ added in v0.0.5
UnmarshalJSON implements the json.Unmarshaler interface to handle a unix milli timestamp and convert it to a Time
type Tx ¶
type Tx interface { Read(ctx context.Context, table string, keys spanner.KeySet, columns []string) *spanner.RowIterator ReadUsingIndex(ctx context.Context, table, index string, keys spanner.KeySet, columns []string) (ri *spanner.RowIterator) ReadWithOptions(ctx context.Context, table string, keys spanner.KeySet, columns []string, opts *spanner.ReadOptions) (ri *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 QueryWithStats(ctx context.Context, statement spanner.Statement) *spanner.RowIterator AnalyzeQuery(ctx context.Context, statement spanner.Statement) (*spannerpb.QueryPlan, error) }
Tx is a common interface for spanner read only and read/write transactions that only read