sqb

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2020 License: MIT Imports: 2 Imported by: 0

README

Simple Query Builder

Simple query builder for build SQL queries

Example

Simple example below

package main

import (
  "github.com/DizoftTeam/sqb"

  "fmt"
)

func main() {
  query := sqb.NewQuery("users as u").
    Select("u.name, u.email").
    Where("and", "u.name = 'Ruslan'").
    Generate()

  // TODO: Here you can use generated query as you want

  fmt.Printf("SQL: %v\n", query)
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Query

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

Query struct for QB

func NewQuery

func NewQuery(tableName string) *Query

NewQuery creates a new query object

func (*Query) Generate

func (q *Query) Generate() string

Generate sql statement

func (*Query) Limit

func (q *Query) Limit(limit int) *Query

Limit sets a limit

func (*Query) Offset

func (q *Query) Offset(offset int) *Query

Offset sets a offset

func (*Query) Select

func (q *Query) Select(expr string) *Query

Select adds a select expression

func (*Query) Where

func (q *Query) Where(whereType string, condition string) *Query

Where adds a where

Jump to

Keyboard shortcuts

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