gormx

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: MIT Imports: 11 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

gormx

gormx is simple starter for gorm, supports follows db:

  • mysql
  • sqlite
  • postgresql
  • sqlserver

Install

go get github.com/ginx-contribs/gormx@latest

Usage

package main

import (
	"github.com/ginx-contribs/dbx"
	"github.com/ginx-contribs/gormx"
	"log"
)

func main() {
	db, err := gormx.Open(gormx.Options{
		Driver:   dbx.Sqlite,
		Database: "test.db",
	})

	if err != nil {
		log.Fatal(err)
	}

	type User struct {
		Name string `gorm:"type:varchar(128);"`
	}

	err = db.Migrator().AutoMigrate(&User{})
	if err != nil {
		log.Fatal(err)
	}
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Open

func Open(options Options, gormOpts ...gorm.Option) (*gorm.DB, error)

Types

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

Logger customizes gorm sql logger with slog.Logger

func NewLogger

func NewLogger(logger *slog.Logger) *Logger

func (*Logger) Error

func (g *Logger) Error(ctx context.Context, s string, i ...interface{})

func (*Logger) Info

func (g *Logger) Info(ctx context.Context, s string, i ...interface{})

func (*Logger) LogMode

func (g *Logger) LogMode(level logger.LogLevel) logger.Interface

func (*Logger) Trace

func (g *Logger) Trace(ctx context.Context, begin time.Time, fc func() (sql string, rowsAffected int64), err error)

func (*Logger) Warn

func (g *Logger) Warn(ctx context.Context, s string, i ...interface{})

type Options

type Options = dbx.Options

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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