db

package
v0.0.0-...-3da28a4 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB struct {
	// Usage. https://entgo.io/ja/docs/crud
	Client *ent.Client
}

func NewConnectMySQL

func NewConnectMySQL() (*DB, error)

Start DB Connection

Use MySQL.

func NewEmptySQL

func NewEmptySQL() (*DB, error)

Connect `empty` table

func (*DB) Close

func (c *DB) Close()

Close DB Connection

func (*DB) WriteSchema

func (c *DB) WriteSchema(ctx context.Context, w io.Writer) error

Write SQL Schema

Used:

f, err := os.Create("schema.sql")
if err != nil {
	log.Fatalf("create migrate file: %v", err)
}
if err := db.WriteSchema(ctx, f); err != nil {
	log.Fatalf("failed %v", err)
}

Jump to

Keyboard shortcuts

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