spanner

package module
v0.0.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 16, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetDBPath

func GetDBPath(projectID, instanceName, dbName string) string

GetDBPath is a simple function that returns the database path to use as argument for spanner.NewClients

func GetOneWithIterator

func GetOneWithIterator(iter *spanner.RowIterator) (row *spanner.Row, exist bool, err error)

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

func ToSpannerKey(args ...interface{}) spanner.Key

ToSpannerKey wrap given arguments and return a spanner.Key

Types

type NullTime added in v0.0.5

type NullTime spanner.NullTime

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

func (nt NullTime) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface to produce a unix milli timestamp

func (*NullTime) UnmarshalJSON added in v0.0.5

func (nt *NullTime) UnmarshalJSON(b []byte) error

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

type Time time.Time

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

func (nt Time) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface to produce a unix milli timestamp

func (*Time) UnmarshalJSON added in v0.0.5

func (nt *Time) UnmarshalJSON(b []byte) error

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL