data

package
v0.0.0-...-cca628e Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2022 License: MIT Imports: 5 Imported by: 0

README

data

generate code from database schema

https://entgo.io/blog/2021/10/11/generating-ent-schemas-from-existing-sql-databases/

go run -mod=mod entgo.io/ent/cmd/ent init

go run ariga.io/entimport/cmd/entimport -dsn "mysql://root:@tcp(localhost:3306)/shopping"

go generate ./ent

TODO

package main

import (
    "time"

    "<your_project>/ent"
    "entgo.io/ent/dialect/sql"
)

func Open() (*ent.Client, error) {
    drv, err := sql.Open("mysql", "<mysql-dsn>")
    if err != nil {
        return nil, err
    }
    // Get the underlying sql.DB object of the driver.
    db := drv.DB()
    db.SetMaxIdleConns(10)
    db.SetMaxOpenConns(100)
    db.SetConnMaxLifetime(time.Hour)
    return ent.NewClient(ent.Driver(drv)), nil
}

https://entgo.io/docs/sql-integration/

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClient

func NewClient(conf static.Config) (*ent.Client, error)

this function should be in a provider set

Types

This section is empty.

Directories

Path Synopsis
ent

Jump to

Keyboard shortcuts

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