Documentation
¶
Index ¶
- func MySQLCount(ctx context.Context, db qrm.DB, fn func(count SelectStatement) SelectStatement) (int64, error)
- func MySQLCreate(ctx context.Context, db qrm.DB, stmt InsertStatement) (int64, error)
- func MySQLDelete(ctx context.Context, db qrm.DB, stmt DeleteStatement) (int64, error)
- func MySQLFindAll[T any](ctx context.Context, db qrm.DB, stmt SelectStatement) ([]T, error)
- func MySQLFindOne[T any](ctx context.Context, db qrm.DB, stmt SelectStatement) (*T, error)
- func MySQLPaginate[T any](ctx context.Context, db qrm.DB, fn func(query SelectStatement) SelectStatement, ...) ([]T, int64, error)
- func MySQLUpdate(ctx context.Context, db qrm.DB, stmt UpdateStatement) (int64, error)
- func PgSQLBatchCreate[T any](ctx context.Context, db qrm.DB, stmt InsertStatement) ([]T, error)
- func PgSQLCount(ctx context.Context, db qrm.DB, fn func(count SelectStatement) SelectStatement) (int64, error)
- func PgSQLCreate[T any](ctx context.Context, db qrm.DB, stmt InsertStatement) (T, error)
- func PgSQLDelete(ctx context.Context, db qrm.DB, stmt DeleteStatement) (int64, error)
- func PgSQLFindAll[T any](ctx context.Context, db qrm.DB, stmt SelectStatement) ([]T, error)
- func PgSQLFindOne[T any](ctx context.Context, db qrm.DB, stmt SelectStatement) (*T, error)
- func PgSQLPaginate[T any](ctx context.Context, db qrm.DB, fn func(query SelectStatement) SelectStatement, ...) ([]T, int64, error)
- func PgSQLUpdate(ctx context.Context, db qrm.DB, stmt UpdateStatement) (int64, error)
- func SQLiteCount(ctx context.Context, db qrm.DB, fn func(count SelectStatement) SelectStatement) (int64, error)
- func SQLiteCreate(ctx context.Context, db qrm.DB, stmt InsertStatement) (int64, error)
- func SQLiteDelete(ctx context.Context, db qrm.DB, stmt DeleteStatement) (int64, error)
- func SQLiteFindAll[T any](ctx context.Context, db qrm.DB, stmt SelectStatement) ([]T, error)
- func SQLiteFindOne[T any](ctx context.Context, db qrm.DB, stmt SelectStatement) (*T, error)
- func SQLitePaginate[T any](ctx context.Context, db qrm.DB, fn func(query SelectStatement) SelectStatement, ...) ([]T, int64, error)
- func SQLiteUpdate(ctx context.Context, db qrm.DB, stmt UpdateStatement) (int64, error)
- type MySQLMap
- type PgSQLMap
- type SQLiteMap
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MySQLCount ¶
func MySQLCount(ctx context.Context, db qrm.DB, fn func(count SelectStatement) SelectStatement) (int64, error)
MySQLCount 返回记录数
// 导入模块
import . "github.com/go-jet/jet/v2/mysql"
// 查询方法
MySQLCount(ctx, db, func(count SelectStatement) SelectStatement {
return count.FROM(table.Demo.Table).WHERE(table.Demo.Name.LIKE(String("%hello%")))
})
func MySQLCreate ¶
MySQLCreate 创建记录
// 导入模块
import . "github.com/go-jet/jet/v2/mysql"
// 语句示例
table.Demo.INSERT(table.Demo.Name).VALUES("hello")
// or
table.Demo.INSERT(table.Demo.Name).MODEL(model.Demo{Name: "hello"})
// 批量插入
table.Demo.INSERT(table.Demo.Name).
VALUES("hello").
VALUES("world")
// or
table.Demo.INSERT(table.Demo.Name).MODELS([]model.Demo{
{Name: "hello"},
{Name: "world"},
})
// 创建方法
MySQLCreate(ctx, db, stmt)
func MySQLDelete ¶
MySQLDelete 删除记录
// 导入模块 import . "github.com/go-jet/jet/v2/mysql" // 语句示例 table.Demo.DELETE().WHERE(table.Demo.ID.EQ(Int64(1))) // 删除方法 MySQLDelete(ctx, db, stmt)
func MySQLFindAll ¶
MySQLFindAll 查询多条记录
// 导入模块
import . "github.com/go-jet/jet/v2/mysql"
// 语句示例
table.Demo.SELECT(table.Demo.AllColumns).WHERE(table.Demo.Name.LIKE(String("%hello%")))
// or
SELECT(table.Demo.AllColumns).FROM(table.Demo).WHERE(table.Demo.Name.LIKE(String("%hello%")))
// 查询方法
MySQLFindAll[model.Demo](ctx, db, stmt)
func MySQLFindOne ¶
MySQLFindOne 查询一条记录
// 导入模块 import . "github.com/go-jet/jet/v2/mysql" // 语句示例 table.Demo.SELECT(table.Demo.AllColumns).WHERE(table.Demo.ID.EQ(Int64(1))) // or SELECT(table.Demo.AllColumns).FROM(table.Demo).WHERE(table.Demo.ID.EQ(Int64(1))) // 查询方法 MySQLFindOne[model.Demo](ctx, db, stmt)
func MySQLPaginate ¶
func MySQLPaginate[T any](ctx context.Context, db qrm.DB, fn func(query SelectStatement) SelectStatement, page, size int, cols ColumnList, orderBy ...OrderByClause) ([]T, int64, error)
MySQLPaginate 分页查询
// 导入模块
import . "github.com/go-jet/jet/v2/mysql"
// 查询方法
MySQLPaginate[model.Demo](ctx, db, func(query SelectStatement) SelectStatement {
return query.FROM(table.Demo.Table).WHERE(table.Demo.Name.LIKE(String("%hello%")))
}, page, size, table.Demo.AllColumns, table.Demo.ID.DESC())
func MySQLUpdate ¶
MySQLUpdate 更新记录
// 导入模块
import . "github.com/go-jet/jet/v2/mysql"
// 语句示例
table.Demo.UPDATE(table.Demo.Name).SET("hello").WHERE(table.Demo.ID.EQ(Int64(1)))
// or
table.Demo.UPDATE(table.Demo.Name).MODEL(model.Demo{Name: "hello"}).WHERE(table.Demo.ID.EQ(Int64(1)))
// 更新方法
MySQLUpdate(ctx, db, stmt)
func PgSQLBatchCreate ¶
PgSQLBatchCreate 批量创建记录
// 导入模块
import . "github.com/go-jet/jet/v2/postgres"
// 语句示例
table.Demo.INSERT(table.Demo.Name).
VALUES("hello").
VALUES("world").
RETURNING(table.Demo.AllColumns)
// or
table.Demo.INSERT(table.Demo.Name).MODELS([]model.Demo{
{Name: "hello"},
{Name: "world"},
}).RETURNING(table.Demo.AllColumns)
// 创建方法
PgSQLBatchCreate[model.Demo](ctx, db, stmt)
func PgSQLCount ¶
func PgSQLCount(ctx context.Context, db qrm.DB, fn func(count SelectStatement) SelectStatement) (int64, error)
PgSQLCount 返回记录数
// 导入模块
import . "github.com/go-jet/jet/v2/postgres"
// 查询方法
PgSQLCount(ctx, db, func(count SelectStatement) SelectStatement {
return count.FROM(table.Demo.Table).WHERE(table.Demo.Name.LIKE(String("%hello%")))
})
func PgSQLCreate ¶
PgSQLCreate 创建记录
// 导入模块
import . "github.com/go-jet/jet/v2/postgres"
// 语句示例
table.Demo.INSERT(table.Demo.Name).VALUES("hello").RETURNING(table.Demo.AllColumns)
// or
table.Demo.INSERT(table.Demo.Name).MODEL(model.Demo{Name: "hello"}).RETURNING(table.Demo.AllColumns)
// 创建方法
PgSQLCreate[model.Demo](ctx, db, stmt)
func PgSQLDelete ¶
PgSQLDelete 删除记录
// 导入模块 import . "github.com/go-jet/jet/v2/postgres" // 语句示例 table.Demo.DELETE().WHERE(table.Demo.ID.EQ(Int64(1))) // 删除方法 PgSQLDelete(ctx, db, stmt)
func PgSQLFindAll ¶
PgSQLFindAll 查询多条记录
// 导入模块
import . "github.com/go-jet/jet/v2/postgres"
// 语句示例
table.Demo.SELECT(table.Demo.AllColumns).WHERE(table.Demo.Name.LIKE(String("%hello%")))
// or
SELECT(table.Demo.AllColumns).FROM(table.Demo).WHERE(table.Demo.Name.LIKE(String("%hello%")))
// 查询方法
PgSQLFindAll[model.Demo](ctx, db, stmt)
func PgSQLFindOne ¶
PgSQLFindOne 查询一条记录
// 导入模块 import . "github.com/go-jet/jet/v2/postgres" // 语句示例 table.Demo.SELECT(table.Demo.AllColumns).WHERE(table.Demo.ID.EQ(Int64(1))) // or SELECT(table.Demo.AllColumns).FROM(table.Demo).WHERE(table.Demo.ID.EQ(Int64(1))) // 查询方法 PgSQLFindOne[model.Demo](ctx, db, stmt)
func PgSQLPaginate ¶
func PgSQLPaginate[T any](ctx context.Context, db qrm.DB, fn func(query SelectStatement) SelectStatement, page, size int, cols ColumnList, orderBy ...OrderByClause) ([]T, int64, error)
PgSQLPaginate 分页查询
// 导入模块
import . "github.com/go-jet/jet/v2/postgres"
// 查询方法
PgSQLPaginate[model.Demo](ctx, db, func(query SelectStatement) SelectStatement {
return query.FROM(table.Demo.Table).WHERE(table.Demo.Name.LIKE(String("%hello%")))
}, page, size, table.Demo.AllColumns, table.Demo.ID.DESC())
func PgSQLUpdate ¶
PgSQLUpdate 更新记录
// 导入模块
import . "github.com/go-jet/jet/v2/postgres"
// 语句示例
table.Demo.UPDATE(table.Demo.Name).SET("hello").WHERE(table.Demo.ID.EQ(Int64(1)))
// or
table.Demo.UPDATE(table.Demo.Name).MODEL(model.Demo{Name: "hello"}).WHERE(table.Demo.ID.EQ(Int64(1)))
// 更新方法
PgSQLUpdate(ctx, db, stmt)
func SQLiteCount ¶
func SQLiteCount(ctx context.Context, db qrm.DB, fn func(count SelectStatement) SelectStatement) (int64, error)
SQLiteCount 返回记录数
// 导入模块
import . "github.com/go-jet/jet/v2/sqlite"
// 查询方法
SQLiteCount(ctx, db, func(count SelectStatement) SelectStatement {
return count.FROM(table.Demo.Table).WHERE(table.Demo.Name.LIKE(String("%hello%")))
})
func SQLiteCreate ¶
SQLiteCreate 创建记录
// 导入模块
import . "github.com/go-jet/jet/v2/sqlite"
// 语句示例
table.Demo.INSERT(table.Demo.Name).VALUES("hello")
// or
table.Demo.INSERT(table.Demo.Name).MODEL(model.Demo{Name: "hello"})
// 批量插入
table.Demo.INSERT(table.Demo.Name).
VALUES("hello").
VALUES("world")
// or
table.Demo.INSERT(table.Demo.Name).MODELS([]model.Demo{
{Name: "hello"},
{Name: "world"},
})
// 创建方法
SQLiteCreate(ctx, db, stmt)
func SQLiteDelete ¶
SQLiteDelete 删除记录
// 导入模块 import . "github.com/go-jet/jet/v2/sqlite" // 语句示例 table.Demo.DELETE().WHERE(table.Demo.ID.EQ(Int64(1))) // 删除方法 SQLiteDelete(ctx, db, stmt)
func SQLiteFindAll ¶
SQLiteFindAll 查询多条记录
// 导入模块
import . "github.com/go-jet/jet/v2/sqlite"
// 语句示例
table.Demo.SELECT(table.Demo.AllColumns).WHERE(table.Demo.Name.LIKE(String("%hello%")))
// or
SELECT(table.Demo.AllColumns).FROM(table.Demo).WHERE(table.Demo.Name.LIKE(String("%hello%")))
// 查询方法
SQLiteFindAll[model.Demo](ctx, db, stmt)
func SQLiteFindOne ¶
SQLiteFindOne 查询一条记录
// 导入模块 import . "github.com/go-jet/jet/v2/sqlite" // 语句示例 table.Demo.SELECT(table.Demo.AllColumns).WHERE(table.Demo.ID.EQ(Int64(1))) // or SELECT(table.Demo.AllColumns).FROM(table.Demo).WHERE(table.Demo.ID.EQ(Int64(1))) // 查询方法 SQLiteFindOne[model.Demo](ctx, db, stmt)
func SQLitePaginate ¶
func SQLitePaginate[T any](ctx context.Context, db qrm.DB, fn func(query SelectStatement) SelectStatement, page, size int, cols ColumnList, orderBy ...OrderByClause) ([]T, int64, error)
SQLitePaginate 分页查询
// 导入模块
import . "github.com/go-jet/jet/v2/sqlite"
// 查询方法
SQLitePaginate[model.Demo](ctx, db, func(query SelectStatement) SelectStatement {
return query.FROM(table.Demo.Table).WHERE(table.Demo.Name.LIKE(String("%hello%")))
}, page, size, table.Demo.AllColumns, table.Demo.ID.DESC())
func SQLiteUpdate ¶
SQLiteUpdate 更新记录
// 导入模块
import . "github.com/go-jet/jet/v2/sqlite"
// 语句示例
table.Demo.UPDATE(table.Demo.Name).SET("hello").WHERE(table.Demo.ID.EQ(Int64(1)))
// or
table.Demo.UPDATE(table.Demo.Name).MODEL(model.Demo{Name: "hello"}).WHERE(table.Demo.ID.EQ(Int64(1)))
// 更新方法
SQLiteUpdate(ctx, db, stmt)
Types ¶
Click to show internal directories.
Click to hide internal directories.