Documentation ¶
Overview ¶
Package spannerddl provides primitives for in-memory modeling the DDL of Spanner databases.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Column ¶
Column represents a Spanner table column.
type Database ¶
type Database struct { // Tables in the database. Tables []*Table // Indexes in the database. Indexes []*Index }
Database represents an in-memory Spanner database.
Example ¶
package main import ( "fmt" "io/ioutil" "path/filepath" "cloud.google.com/go/spanner/spansql" "go.einride.tech/aip-spanner/spanddl" ) func main() { var db spanddl.Database files, err := filepath.Glob("../testdata/migrations/freight/*.up.sql") if err != nil { panic(err) // TODO: Handle error. } for _, file := range files { fileContent, err := ioutil.ReadFile(file) if err != nil { panic(err) // TODO: Handle error. } ddl, err := spansql.ParseDDL(file, string(fileContent)) if err != nil { panic(err) // TODO: Handle error. } if err := db.ApplyDDL(ddl); err != nil { panic(err) // TODO: Handle error. } } for _, table := range db.Tables { fmt.Println(table.Name) } }
Output: shippers sites shipments line_items
func (*Database) ApplyDDL ¶
ApplyDDL applies the provided DDL statement to the database.
func (*Database) Index ¶
Index looks up an index with the provided name.
type Index ¶
Click to show internal directories.
Click to hide internal directories.