Documentation
¶
Overview ¶
Example (GenerateWithSchema) ¶
package main
import (
"context"
"fmt"
"github.com/Jumpaku/schenerate/files"
"github.com/Jumpaku/schenerate/spanner"
)
func main() {
ctx := context.Background()
q, err := spanner.Open(ctx, "<project>", "<instance>", "<database>")
if err != nil {
panic(err)
}
defer q.Close()
err = spanner.GenerateWithSchema(context.Background(), q,
[]string{"Table"},
func(w *files.Writer, schemas spanner.Schemas) error {
for _, schema := range schemas {
// do something with schemas
w.Add(schema.Name)
fmt.Fprintf(w, "%+v\n", schema.Name)
}
return nil
},
)
if err != nil {
panic(err)
}
}
Output:
Index ¶
- func GenerateWithSchema(ctx context.Context, q queryer, tables []string, generator Generator) error
- func ListTables(ctx context.Context, q queryer) ([]string, error)
- func Open(ctx context.Context, project, instance, database string) (queryer, error)
- type Column
- type ForeignKey
- type ForeignKeyReference
- type Generator
- type Index
- type IndexKeyElem
- type Schema
- type Schemas
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateWithSchema ¶
Types ¶
type ForeignKey ¶
type ForeignKey struct {
Name string
Key []string
Reference ForeignKeyReference
}
type ForeignKeyReference ¶
type Index ¶
type Index struct {
Name string
Unique bool
Key []IndexKeyElem
}
type IndexKeyElem ¶
Click to show internal directories.
Click to hide internal directories.