internal

package
v0.0.0-...-08c5772 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2023 License: GPL-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EsType     = "es_type"
	EsAnalyzer = "es_analyzer"
	Json       = "json"
)

Variables

This section is empty.

Functions

func BulkAddDocument

func BulkAddDocument(es *database.Es, ctx context.Context, params ...any) bool

BulkAddDocument 批量添加文档

func BulkDeleteDocument

func BulkDeleteDocument(es *database.Es, ctx context.Context, params ...any) bool

BulkDeleteDocument 批量删除文档

func CreateDocument

func CreateDocument(es *database.Es, ctx context.Context, params ...any) bool

CreateDocument 添加单个文档

func CreateIndex

func CreateIndex(es *database.Es, ctx context.Context, params ...any) bool

CreateIndex 创建索引

func DeleteDocument

func DeleteDocument(es *database.Es, ctx context.Context, params ...any) bool

DeleteDocument 根据文档 id 删除文档

func DeleteIndex

func DeleteIndex(es *database.Es, ctx context.Context, index string) bool

DeleteIndex 删除索引

func GetStructTag

func GetStructTag(t any) esTags

GetStructTag 获取结构体的 elasticsearch 标签 Deprecated: 弃用

func HasIndex

func HasIndex(es *database.Es, ctx context.Context, index string) bool

HasIndex 索引是否存在

func PutMappingByStruct

func PutMappingByStruct(es *database.Es, ctx context.Context, params ...any) bool

PutMappingByStruct 根据结构体更新 mapping

func SearchAggregations

func SearchAggregations(es *database.Es, ctx context.Context, params ...any) (map[string]types.Aggregate, error)

SearchAggregations 聚合数据查询

func SearchDocument

func SearchDocument(es *database.Es, ctx context.Context, params ...any) (any, error)

SearchDocument 根据索引名 index 和 search.Request 条件查询文档

func UpdateDocument

func UpdateDocument(es *database.Es, ctx context.Context, params ...any) bool

UpdateDocument 根据文档 id 更新文档

Types

type ElasticSearchPage

type ElasticSearchPage struct {
	*database.Es
	Index string
	// 用于构建 searchRequest 例如:searchRequest.Query = &types.Query{MatchAll: &types.MatchAllQuery{}} 用于查询所有
	SearchRequest *search.Request
	*pkg.CommonPage
}

func NewElasticSearchPage

func NewElasticSearchPage(es *database.Es, index string, pageNum, pageSize int) *ElasticSearchPage

func (*ElasticSearchPage) Paginate

func (page *ElasticSearchPage) Paginate() error

Paginate 普通数据数据分页

type GormPage

type GormPage struct {
	Db *gorm.DB
	// QueryFunc 查询函数 返回值为 *gorm.DB 类型 用于链式调用 gorm 的查询方法
	// 例如: db.Model(&model).Where("id = ?", id) 传入的 model 为 result 的指针 用于接收查询结果
	// 例如: db.Model(&model).Where("id = ?", id).Find(&model)
	QueryFunc func(*gorm.DB) *gorm.DB
	*pkg.CommonPage
}

func NewGormPage

func NewGormPage(db *gorm.DB, pageNum, pageSize int, orderBy ...string) *GormPage

func (*GormPage) Paginate

func (page *GormPage) Paginate() error

type NativeSqlPage

type NativeSqlPage struct {
	Db *gorm.DB
	// CountSQL 查询总数sql 例如: select count(*) from table where id = ?
	// QuerySQL 查询数据sql 例如: select * from table where id = ?
	CountSQL, QuerySQL string
	// CountArgs 查询总数参数
	// QueryArgs 查询数据参数
	CountArgs, QueryArgs []any
	*pkg.CommonPage
}

func NewNativeSqlPage

func NewNativeSqlPage(db *gorm.DB, pageNum, pageSize int, orderBy ...string) *NativeSqlPage

func (*NativeSqlPage) Paginate

func (page *NativeSqlPage) Paginate() error

Jump to

Keyboard shortcuts

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