Categorygithub.com/tuingking/qbuilder
modulepackage
0.0.2
Repository: https://github.com/tuingking/qbuilder.git
Documentation: pkg.go.dev

# README

qbuilder

query builder for MySQL

Features

  • generate where clause and the arguments for SELECT query based on the params

Examples


type FooParam struct {
    Name sql.NullString `param:"name" db:"name"`
    Age  sql.NullInt64  `param:"age" db:"age"`
}

func GetFoo() {

    // ...

    p := FooParam{
        Name: sql.NullString{Valid:true, String: "foo"}
        Age: sql.NullInt64{Valid:true, Int64: 17}
    }
    
    qb := qbuilder.New()
    wc, args, err := qb.Build(&param)
    if err != nil {
        panic(err)
    }

    fmt.Println("wc", wc)   // WHERE 1=1 AND name=? AND age=? LIMIT 0,10
    fmt.Println("args", wc) // ["foo", 17]
    
    // ...
}

# Packages

No description provided by the author

# Functions

No description provided by the author
No description provided by the author
WithExtraLimit will add 1 extra row.

# Type aliases

No description provided by the author