litequery

package module
v0.0.0-...-23ab395 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2023 License: MIT Imports: 2 Imported by: 0

README

litequery

A simple and fast SQLite query builder library for Go.

Installation

go get github.com/joeychilson/litequery

Queries

  • ANALYZE
  • EXPLAIN
  • PRAGMA
  • SELECT
  • INSERT
  • UPDATE
  • DELETE
  • CREATE TABLE
  • DROP TABLE
  • CREATE INDEX
  • DROP INDEX
  • CREATE VIEW
  • DROP VIEW
  • CREATE TRIGGER
  • DROP TRIGGER
  • ALTER TABLE
  • RENAME TABLE
  • ATTACH
  • DETACH
  • BEGIN
  • COMMIT
  • ROLLBACK
  • SAVEPOINT
  • RELEASE
  • ROLLBACK TO
  • REINDEX
  • VACUUM
  • WITH
  • UNION
  • UNION ALL
  • ORDER BY
  • GROUP BY
  • HAVING
  • LIMIT
  • OFFSET
  • WHERE
  • JOIN
  • INNER JOIN
  • LEFT JOIN
  • RIGHT JOIN
  • FULL JOIN
  • ON
  • USING
  • VALUES
  • SET
  • OR
  • AND
  • NOT
  • LIKE

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Column

type Column struct {
	Name          string
	Type          string
	PrimaryKey    bool
	AutoIncrement bool
	Unique        bool
	NotNull       bool
	Check         string
	Default       string
	Collate       string
	References    string
	OnUpdate      string
	OnDelete      string
}

Column is a struct representing a column in a CREATE TABLE statement

type Field

type Field struct {
	Name     string
	Value    any
	IsColumn bool
}

Field is a struct that represents a field in a table

type Query

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

Query is a struct that represents a query

func AlterTable

func AlterTable(table string) *Query

AlterTableName is a function that returns a RENAME TABLE query

func Analyze

func Analyze(query string) *Query

Analyze is a function that returns an ANALYZE query

func AttachDatabase

func AttachDatabase(schema, name string) *Query

AttachDatabase is a function that returns an ATTACH DATABASE query

func Begin

func Begin(mode string) *Query

Begin is a function that returns a BEGIN TRANSACTION query with the specified mode

func CreateIndex

func CreateIndex(name, table string, columns []string, unique bool) *Query

CreateIndex is a function that returns a CREATE INDEX query for the specified index and columns

func CreateTable

func CreateTable(name string, columns []*Column, options ...string) *Query

CreateTable is a function that returns a CREATE TABLE query with the specified options

func CreateTrigger

func CreateTrigger(name, table, when, event, actions string) *Query

CreateTrigger is a function that returns a CREATE TRIGGER query for the specified trigger

func CreateView

func CreateView(name, query string, temp bool, ifNotExists bool) *Query

CreateView is a function that returns a CREATE VIEW query for the specified view and SQL statement

func DeleteFrom

func DeleteFrom(table string) *Query

DeleteFrom is a function to start building a DELETE FROM query statement

func DetachDatabase

func DetachDatabase(name string) *Query

DetachDatabase is a function that returns a DETACH DATABASE query

func DropIndex

func DropIndex(name string) *Query

DropIndex is a function that returns a DROP INDEX query for the specified index

func DropTable

func DropTable(table string) *Query

DropTable is a function that returns a DROP TABLE query for the specified table

func DropTrigger

func DropTrigger(name string) *Query

DropTrigger is a function that returns a DROP TRIGGER query for the specified trigger

func DropView

func DropView(name string) *Query

DropView is a function that returns a DROP VIEW query for the specified view

func Explain

func Explain(query string) *Query

Explain is a function that returns an EXPLAIN query

func InsertInto

func InsertInto(table string) *Query

InsertInto is a function to start building an INSERT INTO query statement

func Pragma

func Pragma(name, value string) *Query

Pragma is a function that returns a PRAGMA query

func ReleaseSavepoint

func ReleaseSavepoint(name string) *Query

ReleaseSavepoint is a function that adds a RELEASE SAVEPOINT statement to the query for the specified savepoint name

func Rollback

func Rollback(savepoint string) *Query

Rollback is a function that returns a ROLLBACK TRANSACTION query

func Savepoint

func Savepoint(name string) *Query

Savepoint is a function that adds a SAVEPOINT statement to the query for the specified savepoint name

func Select

func Select(conditions ...string) *Query

Select is a function to start building a SELECT query statement

func Update

func Update(table, condition string) *Query

Update is a function to start building an UPDATE query statement

func Vacuum

func Vacuum(schema, file string) *Query

Vacuum is a function that returns a VACUUM statement for the specified schema and file

func With

func With(queries ...*WithQuery) *Query

With is a function that returns a WITH clause for the specified name and query

func (*Query) AddColumn

func (q *Query) AddColumn(column Column, options ...string) *Query

AddColumn is a function that returns an ADD COLUMN query

func (*Query) AlterTable

func (q *Query) AlterTable(table string) *Query

AlterTableName builds the query string for a RENAME TABLE statement

func (*Query) Analyze

func (q *Query) Analyze(query string) *Query

Analyze is a function that returns an ANALYZE query

func (*Query) And

func (q *Query) And(condition string) *Query

And is a function that returns an AND WHERE clause for the specified expression and value

func (*Query) Args

func (q *Query) Args(args ...any) *Query

Args is a function that appends arguments to the query

func (*Query) Asc

func (q *Query) Asc() *Query

Asc is a function that specifies ascending sort order for the most recently specified column in the ORDER BY clause

func (*Query) AttachDatabase

func (q *Query) AttachDatabase(schema, name string) *Query

AttachDatabase is a function that returns an ATTACH DATABASE query

func (*Query) Begin

func (q *Query) Begin(mode string) *Query

Begin is a function that returns a BEGIN TRANSACTION query with the specified mode

func (*Query) Build

func (q *Query) Build() (string, []any)

Build is a function that returns the query string and arguments

func (*Query) Columns

func (q *Query) Columns(columns ...string) *Query

Columns builds the query string for the COLUMNS clause in an INSERT INTO statement

func (*Query) Commit

func (q *Query) Commit() *Query

Commit is a function that returns a COMMIT TRANSACTION query

func (*Query) CreateIndex

func (q *Query) CreateIndex(name, table string, columns []string, unique bool) *Query

CreateIndex is a function that returns a CREATE INDEX query for the specified index and columns

func (*Query) CreateTable

func (q *Query) CreateTable(name string, columns []*Column, options ...string) *Query

CreateTable is a function that returns a CREATE TABLE query with the specified options

func (*Query) CreateTrigger

func (q *Query) CreateTrigger(name, table, when, event, actions string) *Query

CreateTrigger is a function that returns a CREATE TRIGGER query for the specified trigger

func (*Query) CreateView

func (q *Query) CreateView(name, query string, temp bool, ifNotExists bool) *Query

CreateView is a function that returns a CREATE VIEW query for the specified view and SQL statement

func (*Query) DeleteFrom

func (q *Query) DeleteFrom(table string) *Query

DeleteFrom is a method for the Query struct and builds the query string for a DELETE statement

func (*Query) Desc

func (q *Query) Desc() *Query

Desc is a function that specifies descending sort order for the most recently specified column in the ORDER BY clause

func (*Query) DetachDatabase

func (q *Query) DetachDatabase(name string) *Query

DetachDatabase is a function that returns a DETACH DATABASE query

func (*Query) Do

func (q *Query) Do() *Query

Do is a function to start building a DO query statement

func (*Query) DropColumn

func (q *Query) DropColumn(columnName string) *Query

DropColumn is a function that returns a DROP COLUMN query

func (*Query) DropIndex

func (q *Query) DropIndex(name string) *Query

DropIndex is a function that returns a DROP INDEX query for the specified index

func (*Query) DropTable

func (q *Query) DropTable(table string) *Query

DropTable is a function that returns a DROP TABLE query for the specified table

func (*Query) DropTrigger

func (q *Query) DropTrigger(name string) *Query

DropTrigger is a function that returns a DROP TRIGGER query for the specified trigger

func (*Query) DropView

func (q *Query) DropView(name string) *Query

DropView is a function that returns a DROP VIEW query for the specified view

func (*Query) Explain

func (q *Query) Explain(query string) *Query

Explain is a function that returns an EXPLAIN query

func (*Query) From

func (q *Query) From(tables ...string) *Query

From is a function that returns a FROM clause for the specified tables

func (*Query) FullJoin

func (q *Query) FullJoin(table, condition string) *Query

FullJoin is a function that returns a FULL JOIN clause for the specified tables

func (*Query) GroupBy

func (q *Query) GroupBy(conditions ...string) *Query

GroupBy is a function that returns a GROUP BY clause for the specified columns

func (*Query) Having

func (q *Query) Having(condition string) *Query

Having is a function that adds a HAVING clause to the query for the specified conditions

func (*Query) In

func (q *Query) In(values []any) *Query

In is a function that returns an IN WHERE clause for the specified column and values Values are automatically added as query arguments

func (*Query) IndexBy

func (q *Query) IndexBy(name string) *Query

IndexBy is a function that returns an INDEX BY clause for the specified index

func (*Query) InsertInto

func (q *Query) InsertInto(table string) *Query

InsertInto builds the query string for an INSERT INTO statement

func (*Query) Join

func (q *Query) Join(table, condition string) *Query

Join is a function that returns a JOIN clause for the specified tables

func (*Query) LeftJoin

func (q *Query) LeftJoin(table, condition string) *Query

LeftJoin is a function that returns a LEFT JOIN clause for the specified tables

func (*Query) Like

func (q *Query) Like(pattern string) *Query

Like is a function that returns a LIKE WHERE clause for the specified column and value

func (*Query) Limit

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

Limit is a function that specifies the maximum number of rows to return

func (*Query) Not

func (q *Query) Not() *Query

Not is a function that returns a NOT WHERE clause for the specified expression and value

func (*Query) NotIndex

func (q *Query) NotIndex() *Query

NotIndex is a function that returns a NOT INDEX clause

func (*Query) Nothing

func (q *Query) Nothing() *Query

Nothing is a function that returns a NOTHING clause for the specified fields

func (*Query) Offset

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

Offset is a function that specifies the number of rows to skip before starting to return rows

func (*Query) OnConflict

func (q *Query) OnConflict(columns ...string) *Query

OnConflict builds the query string for the ON CONFLICT clause in an INSERT INTO statement

func (*Query) Or

func (q *Query) Or(condition string) *Query

Or is a function that returns an OR WHERE clause for the specified expression and value

func (*Query) OrderBy

func (q *Query) OrderBy(columns ...string) *Query

OrderBy is a function that returns an ORDER BY clause for the specified columns and sort order

func (*Query) Paginate

func (q *Query) Paginate(page, pageSize int) *Query

Paginate is a function that returns a LIMIT and OFFSET clause for the specified page and page size

func (*Query) Pragma

func (q *Query) Pragma(name, value string) *Query

Pragma is a function that returns a PRAGMA query

func (*Query) Query

func (q *Query) Query() string

Query is a function that returns the query string

func (*Query) Raw

func (q *Query) Raw(query string, args ...any) *Query

Raw is a function that returns a raw query string and arguments

func (*Query) Reindex

func (q *Query) Reindex(name string) *Query

Reindex is a function that returns a REINDEX clause

func (*Query) ReleaseSavepoint

func (q *Query) ReleaseSavepoint(name string) *Query

ReleaseSavepoint is a function that adds a RELEASE SAVEPOINT statement to the query for the specified savepoint name

func (*Query) RenameColumn

func (q *Query) RenameColumn(oldName, newName string) *Query

RenameColumn is a function that returns a RENAME COLUMN query

func (*Query) RenameTo

func (q *Query) RenameTo(newName string) *Query

RenameTo is a function that returns a RENAME TO query

func (*Query) Reset

func (q *Query) Reset()

Reset is a function that resets the query string and arguments

func (*Query) Returning

func (q *Query) Returning(columns ...string) *Query

Returning is a function that returns a RETURNING clause for the specified columns

func (*Query) RightJoin

func (q *Query) RightJoin(table, condition string) *Query

RightJoin is a function that returns a RIGHT JOIN clause for the specified tables

func (*Query) Rollback

func (q *Query) Rollback(savepoint string) *Query

Rollback is a function that returns a ROLLBACK TRANSACTION query

func (*Query) Savepoint

func (q *Query) Savepoint(name string) *Query

Savepoint is a function that adds a SAVEPOINT statement to the query for the specified savepoint name

func (*Query) Select

func (q *Query) Select(conditions ...string) *Query

Select is a function that returns a SELECT query for the specified columns and tables, with optional conditions

func (*Query) Set

func (q *Query) Set(fields []*Field) *Query

Set is a function that returns a SET clause for the specified fields

func (*Query) Union

func (q *Query) Union() *Query

Union is a function that returns a UNION clause for the specified tables

func (*Query) UnionAll

func (q *Query) UnionAll() *Query

UnionAll is a function that returns a UNION ALL clause for the specified tables

func (*Query) Update

func (q *Query) Update(table, condition string) *Query

Update is a function that returns an UPDATE query for the specified table and condition

func (*Query) Vacuum

func (q *Query) Vacuum(schema, file string) *Query

Vacuum is a function that returns a VACUUM statement for the specified schema and file

func (*Query) Values

func (q *Query) Values(values ...any) *Query

Values builds the query string for the VALUES clause in an INSERT INTO statement

func (*Query) Where

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

Where is a function that returns a WHERE clause for the specified expression and value

func (*Query) With

func (q *Query) With(queries ...*WithQuery) *Query

With is a function that returns a WITH clause for the specified name and query

type WithQuery

type WithQuery struct {
	Name  string
	Query *Query
}

WithQuery is a struct that represents a WITH clause

Jump to

Keyboard shortcuts

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