horm

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2024 License: Apache-2.0 Imports: 21 Imported by: 5

Documentation

Overview

Package horm mysql 查询语句封装包

Index

Constants

View Source
const Version = 1 // orm client version v1,影响查询语句

Variables

This section is empty.

Functions

func GetDBConfig

func GetDBConfig(name string) (*dbConfig, error)

GetDBConfig 获取数据库配置

func IsAllSuccess

func IsAllSuccess(results []*proto.ModResult) bool

IsAllSuccess 判断 es 批量插入是否全部成功

func LoadConfig

func LoadConfig(confPath ...string)

LoadConfig 加载配置文件

func SetGlobalClient

func SetGlobalClient(name string, opts ...Option)

SetGlobalClient 设置全局查询语句执行客户端。 param: name 配置名 param: opts 参数配置

Types

type AND

type AND map[string]interface{}

AND 关联词

type Client

type Client interface {
	Exec(ctx context.Context, q *Query, retReceiver ...interface{}) (isNil bool, err error)
	PExec(ctx context.Context, q *Query) error
	CompExec(ctx context.Context, q *Query, retReceiver interface{}) error
}

Client 查询语句执行客户端

var GlobalClient Client // 全局查询语句执行客户端

func NewClient

func NewClient(name string, opts ...Option) Client

NewClient 创建查询语句执行客户端 param: name 配置名 param: opts 参数配置

type Error

type Error proto.Error

Error 返回信息

type IN

type IN []interface{}

IN select * from table where column in (1, 2, 3)

type Map

type Map map[string]interface{}

Map 更新操作 map 数据声明

type OR

type OR map[string]interface{}

OR 关联词

type On

type On map[string]string

On sql join On 结构声明

type Option

type Option func(*Options)

Option sets client options.

func WithAppID

func WithAppID(appid uint64) Option

WithAppID returns an Option that sets appid.

func WithCaller

func WithCaller(caller string) Option

WithCaller returns an Option that sets caller service name of client.

func WithEncryption

func WithEncryption(token string) Option

WithEncryption returns an Option that sets encryption of frame.

func WithLocalIP

func WithLocalIP(ip string) Option

WithLocalIP returns an Option that sets ip of client.

func WithLocation

func WithLocation(region, zone, compus string) Option

WithLocation returns an Option that sets location of client.

func WithSecret

func WithSecret(secret string) Option

WithSecret returns an Option that sets appid`s secret.

func WithTarget

func WithTarget(target string) Option

WithTarget returns an Option that sets target of server.

func WithTimeout

func WithTimeout(timeout uint32) Option

WithTimeout returns an Option that sets timeout of server.

func WithToken

func WithToken(token string) Option

WithToken returns an Option that sets token of workspace of server.

func WithWorkspaceID

func WithWorkspaceID(workspaceID int) Option

WithWorkspaceID returns an Option that sets workspace of server.

type Options

type Options struct {
	WorkspaceID int    // workspace id
	Encryption  int8   // frame encryption
	Token       string // workspace token
	Timeout     uint32 // timeout Millisecond
	Caller      string // caller name
	Appid       uint64 // appid
	Secret      string // secret
	Target      string // server target address
	LocalIP     string // 本地 ip
	Location    struct {
		Region string // 区域
		Zone   string // 城市
		Compus string // 园区
	}
}

Options are client options.

type Query

type Query struct {
	Unit *proto.Unit // 请求单元

	Client      Client        // 客户端
	Error       error         // Query 语句错误
	Key         string        // 语句 key
	Receiver    []interface{} // 结果接收
	IsNil       *bool         // 是否包含空值
	RespError   *error        // 返回错误
	Compress    bool          // 是否压缩 false - 不压缩 true - 压缩
	ResultType  int8          // 返回数据类型
	Coder       codec.Codec   // 数据编解码器
	RequestID   uint64        // 请求 id
	TraceID     string        // 请求 trace_id
	RequestBody []byte        // 请求体
	// contains filtered or unexported fields
}

Query 请求语句

func NewQuery

func NewQuery(name string) *Query

NewQuery 创建新执行语句 param: name 为执行语句名称

func NewTransaction

func NewTransaction(transName string, trans *Query) *Query

NewTransaction 创建一个事务语句 param: trans 为该事务所有执行语句,所有语句必须全部成功或失败。注意:仅支持带事务功能的数据库回滚。

func (*Query) AddNext

func (s *Query) AddNext(nexts ...*Query) *Query

AddNext 将输入的语句串联到本语句并行执行上。 param: nexts 需要被串联的并行执行的所有语句

func (*Query) AddSub

func (s *Query) AddSub(sub *Query) *Query

AddSub 新增嵌套子查询语句

func (*Query) Between

func (s *Query) Between(key string, start, end interface{}) *Query

func (*Query) BitCount

func (s *Query) BitCount(key string, start, end int) *Query

BitCount 计算给定字符串中,被设置为 1 的比特位的数量 param: key string param: start int 可以使用负数值: 比如 -1 表示最后一个字节, -2 表示倒数第二个字节,以此类推 param: end int 可以使用负数值: 比如 -1 表示最后一个字节, -2 表示倒数第二个字节,以此类推

func (*Query) Bytes

func (s *Query) Bytes(bs []byte) *Query

Bytes 字节码

func (*Query) Collapse

func (s *Query) Collapse(field string) *Query

Collapse collapse search results

func (*Query) Column

func (s *Query) Column(columns ...string) *Query

Column 列

func (*Query) CompExec

func (s *Query) CompExec(ctx context.Context, retReceiver interface{}) error

CompExec 复合查询

func (*Query) Create

func (s *Query) Create(name, shard string, ifNotExists ...bool) *Query

Create 创建表

func (*Query) Decr

func (s *Query) Decr(key string) *Query

Decr 将 key 中储存的数字值减一。如果 key 不存在,那么 key 的值会先被初始化为 0 ,然后再执行 DECR 操作。如果值包含错误的类型,或字符串类型的值不能表示为数字,那么返回一个错误。 param: key string

func (*Query) Del

func (s *Query) Del(key string) *Query

Del 删除已存在的键。不存在的 key 会被忽略。 param: key string

func (*Query) Delete

func (s *Query) Delete(where ...Where) *Query

Delete 根据条件删除

func (*Query) DeleteBy

func (s *Query) DeleteBy(key string, value interface{}, kvs ...interface{}) *Query

DeleteBy delete where key1=value1 AND key2=value2 ... input must be key, value, key, value, key, value ...

func (*Query) Eq

func (s *Query) Eq(key string, value interface{}, kvs ...interface{}) *Query

Eq equal mean where key1=value1 AND key2=value2 ... input must be key, value, key, value, key, value ...

func (*Query) Exec

func (s *Query) Exec(ctx context.Context, retReceiver ...interface{}) (isNil bool, err error)

Exec 执行单个操作单元

func (*Query) Exists

func (s *Query) Exists(key string) *Query

Exists 查看值是否存在 exists param: key string

func (*Query) Expire

func (s *Query) Expire(key string, ttl int) *Query

Expire 设置 key 的过期时间,key 过期后将不再可用。单位以秒计。 param: key string param: int ttl 到期时间,ttl秒

func (*Query) Extend

func (s *Query) Extend(key string, value interface{}) *Query

Extend 扩展信息会被传入到每个插件。用于自定义功能

func (*Query) Find

func (s *Query) Find(where ...Where) *Query

Find 查询满足条件的一条数据

func (*Query) FindAll

func (s *Query) FindAll(where ...Where) *Query

FindAll 查询满足条件的所有数据

func (*Query) FindAllBy

func (s *Query) FindAllBy(key string, value interface{}, kvs ...interface{}) *Query

FindAllBy find_all where key1=value1 AND key2=value2 ... input must be key, value, key, value, key, value ...

func (*Query) FindBy

func (s *Query) FindBy(key string, value interface{}, kvs ...interface{}) *Query

FindBy find where key1=value1 AND key2=value2 ... input must be key, value, key, value, key, value ...

func (*Query) Get

func (s *Query) Get(key string) *Query

Get 获取指定 key 的值。如果 key 不存在,返回 nil 。可用 IsNil(err) 判断是否key不存在,如果key储存的值不是字符串类型,返回一个错误。 param: key string

func (*Query) GetBit

func (s *Query) GetBit(key string, offset uint32) *Query

GetBit 获取指定偏移量上的位 param: key string param: offset uint32 参数必须大于或等于 0 ,小于 2^32 (bit 映射被限制在 512 MB 之内)

func (*Query) GetCoder

func (s *Query) GetCoder() codec.Codec

GetCoder 获取编解码器

func (*Query) GetHead

func (s *Query) GetHead() *Query

GetHead 获取头部

func (*Query) GetSet

func (s *Query) GetSet(key string, v interface{}) *Query

GetSet 设置给定 key 的值。如果 key 已经存储其他值, GetSet 就覆写旧值,并返回原来的值,如果原来未设置值,则返回报错 nil returned param: key string param: v interface{} 任意类型数据

func (*Query) Group

func (s *Query) Group(group ...string) *Query

Group 分组

func (*Query) Gt

func (s *Query) Gt(key string, value interface{}) *Query

func (*Query) Gte

func (s *Query) Gte(key string, value interface{}) *Query

func (*Query) HDel

func (s *Query) HDel(key string, field ...interface{}) *Query

HDel 删除哈希表 key 中的一个或多个指定字段,不存在的字段将被忽略。 param: keyfield interface{},删除指定key的field数据,这里输入的第一参数为key,其他为多个field,至少得有一个field

func (*Query) HExists

func (s *Query) HExists(key string, field interface{}) *Query

HExists 查看哈希表的指定字段是否存在。 param: key string param: field interface{}

func (*Query) HGet

func (s *Query) HGet(key string, field interface{}) *Query

HGet 数据从redis hget 出来之后反序列化并赋值给 v param: key string param: field string

func (*Query) HGetAll

func (s *Query) HGetAll(key string) *Query

HGetAll 返回哈希表中,所有的字段和值。 param: key string

func (*Query) HIncrBy

func (s *Query) HIncrBy(key string, field string, v int) *Query

HIncrBy 为哈希表中的字段值加上指定增量值。 param: key string param: field string param: n string 自增数量

func (*Query) HIncrByFloat

func (s *Query) HIncrByFloat(key string, field string, v float64) *Query

HIncrByFloat 为哈希表中的字段值加上指定增量浮点数。 param: key string param: field string param: v float64 自增数量

func (*Query) HLen

func (s *Query) HLen(key string) *Query

HLen 获取哈希表中字段的数量。 param: key string

func (*Query) HSet

func (s *Query) HSet(key string, field, v interface{}, args ...interface{}) *Query

HSet 为哈希表中的字段赋值 。 param: key string param: field interface{} 其中field建议为字符串,可以为整数,浮点数 param: v interface{} 任意类型数据 param: args ...interface{} 多条数据,按照filed,value 的格式,其中field建议为字符串,可以为整数,浮点数

func (*Query) HSetNx

func (s *Query) HSetNx(key string, filed interface{}, value interface{}) *Query

HSetNx 为哈希表中不存在的的字段赋值 。 param: key string param: field string param: value interface{}

func (*Query) HStrLen

func (s *Query) HStrLen(key string, field interface{}) *Query

HStrLen 获取哈希表某个字段长度。 param: key string param: field string

func (*Query) HVals

func (s *Query) HVals(key string) *Query

HVals 返回所有的 value param: key string

func (*Query) Having

func (s *Query) Having(having Where) *Query

Having 分组条件

func (*Query) HighLight

func (s *Query) HighLight(fields []string, preTag, postTag string) *Query

HighLight 返回高亮

func (*Query) Hkeys

func (s *Query) Hkeys(key string) *Query

Hkeys 获取哈希表中的所有域(field)。 param: key string

func (*Query) HmGet

func (s *Query) HmGet(key string, fields ...string) *Query

HmGet 返回哈希表中,一个或多个给定字段的值。 param: key string param: fields string 需要返回的域

func (*Query) HmSet

func (s *Query) HmSet(key string, v interface{}) *Query

HmSet 把 map/struct 数据设置到哈希表中。此命令会覆盖哈希表中已存在的字段。如果哈希表不存在,会创建一个空哈希表,并执行 HMSET 操作。 param: key string param: v 必须是 map[string]interface{} 、或者 struct

func (*Query) ID

func (s *Query) ID(value interface{}) *Query

ID 主键 _id 查询

func (*Query) Incr

func (s *Query) Incr(key string) *Query

Incr 将 key 中储存的数字值增一。 如果 key 不存在,那么 key 的值会先被初始化为 0 ,然后再执行 INCR 操作。 如果值包含错误的类型,或字符串类型的值不能表示为数字,那么返回一个错误。 param: key string

func (*Query) IncrBy

func (s *Query) IncrBy(key string, n int) *Query

IncrBy 将 key 中储存的数字加上指定的增量值。如果 key 不存在,那么 key 的值会先被初始化为 0 ,然后再执行 INCRBY 命令。如果值包含错误的类型,或字符串类型的值不能表示为数字,那么返回一个错误。 param: key string param: n string 自增数量

func (*Query) Insert

func (s *Query) Insert(data interface{}) *Query

Insert (批量)插入数据,参数可以是 struct / []struct / Map / []Map

func (*Query) LLen

func (s *Query) LLen(key string) *Query

LLen 返回列表的长度。 如果列表 key 不存在,则 key 被解释为一个空列表,返回 0 。 如果 key 不是列表类型,返回一个错误。 param: key string

func (*Query) LPop

func (s *Query) LPop(key string) *Query

LPop 移除并返回列表的第一个元素。 param: key string

func (*Query) LPush

func (s *Query) LPush(key string, v ...interface{}) *Query

LPush 将一个或多个值插入到列表头部。 如果 key 不存在,一个空列表会被创建并执行 LPUSH 操作。 当 key 存在但不是列表类型时,返回一个错误。 param: key string param: v interface{} 任意类型数据

func (*Query) Like

func (s *Query) Like(key string, value interface{}) *Query

func (*Query) Limit

func (s *Query) Limit(limit int, offset ...uint64) *Query

Limit 排序

func (*Query) Lt

func (s *Query) Lt(key string, value interface{}) *Query

func (*Query) Lte

func (s *Query) Lte(key string, value interface{}) *Query

func (*Query) MGet

func (s *Query) MGet(keys ...string) *Query

MGet 返回多个 key 的 value param: keys string

func (*Query) MSet

func (s *Query) MSet(values map[string]interface{}) *Query

MSet 批量设置一个或多个 key-value 对 param: values map[string]interface{} // value will marshal 注意,本接口 Prefix 一定要在 MSet 之前设置,这里所有的 key 都会被加上 Prefix

func (*Query) Match

func (s *Query) Match(key string, value interface{}) *Query

func (*Query) MatchPhrase

func (s *Query) MatchPhrase(key string, value interface{}) *Query

func (*Query) Name

func (s *Query) Name(name string) *Query

Name 设置执行语句名称

func (*Query) Next

func (s *Query) Next(name string) *Query

Next 创建下一条并发执行语句 param: name 为执行语句名称

func (*Query) Not

func (s *Query) Not(key string, value interface{}) *Query

func (*Query) NotBetween

func (s *Query) NotBetween(key string, start, end interface{}) *Query

func (*Query) NotLike

func (s *Query) NotLike(key string, value interface{}) *Query

func (*Query) NotMatch

func (s *Query) NotMatch(key string, value interface{}) *Query

func (*Query) NotMatchPhrase

func (s *Query) NotMatchPhrase(key string, value interface{}) *Query

func (*Query) Op

func (s *Query) Op(op string) *Query

Op 设置操作

func (*Query) Order

func (s *Query) Order(orders ...string) *Query

Order 排序, 首字母 + 表示升序,- 表示降序

func (*Query) PExec

func (s *Query) PExec(ctx context.Context) error

PExec 并行执行多个操作单元

func (*Query) Page

func (s *Query) Page(page, pageSize int) *Query

Page 分页

func (*Query) Prefix

func (s *Query) Prefix(prefix string) *Query

Prefix redis 操作

func (*Query) RPop

func (s *Query) RPop(key string) *Query

RPop 移除列表的最后一个元素,返回值为移除的元素。 param: key string

func (*Query) RPush

func (s *Query) RPush(key string, v ...interface{}) *Query

RPush 将一个或多个值插入到列表的尾部(最右边)。如果列表不存在,一个空列表会被创建并执行 RPUSH 操作。 当列表存在但不是列表类型时,返回一个错误。 param: key string param: v interface{} 任意类型数据

func (*Query) Refresh

func (s *Query) Refresh() *Query

Refresh 更新数据立即刷新

func (*Query) Replace

func (s *Query) Replace(data interface{}) *Query

Replace (批量)替换数据,参数可以是 struct / []struct / Map / []Map

func (*Query) Reset

func (s *Query) Reset() *Query

Reset 语句初始化

func (*Query) Routing

func (s *Query) Routing(routing string) *Query

Routing 路由

func (*Query) SAdd

func (s *Query) SAdd(key string, v ...interface{}) *Query

SAdd 将一个或多个成员元素加入到集合中,已经存在于集合的成员元素将被忽略。 param: key string param: v ...interface{} 任意类型的多条数据,但是务必确保各条数据的类型保持一致

func (*Query) SCard

func (s *Query) SCard(key string) *Query

SCard 返回集合中元素的数量。 param: key string

func (*Query) SIsMember

func (s *Query) SIsMember(key string, member interface{}) *Query

SIsMember 判断成员元素是否是集合的成员。 param: key string param: member interface{} 要检索的任意类型数据

func (*Query) SMembers

func (s *Query) SMembers(key string) *Query

SMembers 返回集合中的所有的成员。 不存在的集合 key 被视为空集合。 param: key string

func (*Query) SMove

func (s *Query) SMove(source, destination string, member interface{}) *Query

SMove 将指定成员 member 元素从 source 集合移动到 destination 集合。 param: source string param: destination string param: member interface{} 要移动的成员,任意类型

func (*Query) SPop

func (s *Query) SPop(key string, count int) *Query

SPop 移除集合中的指定 key 的一个或多个随机成员,移除后会返回移除的成员。 param: key string param: int count

func (*Query) SRandMember

func (s *Query) SRandMember(key string, count int) *Query

SRandMember 返回集合中的count个随机元素。 param: key string param: count int 随机返回元素个数。 如果 count 为正数,且小于集合基数,那么命令返回一个包含 count 个元素的数组,数组中的元素各不相同。 如果 count 大于等于集合基数,那么返回整个集合。 如果 count 为负数,那么命令返回一个数组,数组中的元素可能会重复出现多次,而数组的长度为 count 的绝对值。

func (*Query) SRem

func (s *Query) SRem(key string, members ...interface{}) *Query

SRem 移除集合中的一个或多个成员元素,不存在的成员元素会被忽略 param: key string param: v ...interface{} 任意类型的多条数据

func (*Query) Scroll

func (s *Query) Scroll(scroll string, size int, where ...Where) *Query

Scroll 查询,size 为每次 scroll 大小,where 为 scroll 条件。

func (*Query) ScrollByID

func (s *Query) ScrollByID(id string) *Query

ScrollByID 根据 scrollID 滚动查询。

func (*Query) Set

func (s *Query) Set(key string, value interface{}, args ...interface{}) *Query

Set 设置给定 key 的值。如果 key 已经存储其他值, Set 就覆写旧值。 param: key string param: value interface{} 任意类型数据 param: args ...interface{} set的其他参数

func (*Query) SetBit

func (s *Query) SetBit(key string, offset uint32, value bool) *Query

SetBit 设置或清除指定偏移量上的位 param: key string param: offset uint32 参数必须大于或等于 0 ,小于 2^32 (bit 映射被限制在 512 MB 之内) param: value bool true:设置为1,false:设置为0

func (*Query) SetCompress

func (s *Query) SetCompress() *Query

SetCompress 压缩,调用该方法表示数据将通过Gzip压缩传递

func (*Query) SetEX

func (s *Query) SetEX(key string, v interface{}, ttl int) *Query

SetEX 指定的 key 设置值及其过期时间。如果 key 已经存在, SETEX 命令将会替换旧的值。 param: key string param: v interface{} 任意类型数据 param: ttl int 到期时间

func (*Query) SetNX

func (s *Query) SetNX(key string, v interface{}) *Query

SetNX redis.SetNX 指定的 key 不存在时,为 key 设置指定的值。 param: key string param: v interface{} 任意类型数据

func (*Query) SetParam

func (s *Query) SetParam(key string, value interface{}) *Query

SetParam 与数据库相关的请求参数,例如 redis 的 WITHSCORES, elastic 的 collapse、runtime_mappings、track_total_hits 等等。

func (*Query) Shard

func (s *Query) Shard(shard ...string) *Query

Shard 分片、分表

func (*Query) Source

func (s *Query) Source(q string, args ...interface{}) *Query

Source 直接输入查询语句查询

func (*Query) TTL

func (s *Query) TTL(key string) *Query

TTL 以秒为单位返回 key 的剩余过期时间。 param: string key

func (*Query) Type

func (s *Query) Type(typ string) *Query

Type elastic search 版本 v7 以前有 type, v7之后 type 统一为 _doc

func (*Query) Update

func (s *Query) Update(data interface{}, where ...Where) *Query

Update 更新数据,参数可以是 struct / Map

func (*Query) UpdateKV

func (s *Query) UpdateKV(key string, value interface{}, kvs ...interface{}) *Query

UpdateKV 更新字段,快速更新键值对 key = value

func (*Query) Where

func (s *Query) Where(where Where) *Query

Where 查询条件

func (*Query) WithClient

func (s *Query) WithClient(c Client) *Query

WithClient 设置查询客户端

func (*Query) WithCoder

func (s *Query) WithCoder(coder codec.Codec) *Query

WithCoder 更换编解码器

func (*Query) WithReceiver

func (s *Query) WithReceiver(nilReceiver *bool, errReceiver *error, receiver ...interface{}) *Query

WithReceiver 接收返回,主要用于并发查询

func (*Query) WithRequestID

func (s *Query) WithRequestID(id uint64) *Query

WithRequestID 设置 request_id

func (*Query) WithTraceID

func (s *Query) WithTraceID(id string) *Query

WithTraceID 设置 trace_id

func (*Query) ZAdd

func (s *Query) ZAdd(key string, args ...interface{}) *Query

ZAdd redis.ZAdd 将成员元素及其分数值加入到有序集当中。如果某个成员已经是有序集的成员,那么更新这个成员的分数值,并通过重新插入这个成员元素, 来保证该成员在正确的位置上。分数值可以是整数值或双精度浮点数。 param: key string param: args ...interface{} 添加更多成员,需要按照 member, score, member, score 依次排列 注意:⚠️ 与 redis 命令不一样,需要按照 member, score, member, score, 格式传入

func (*Query) ZCard

func (s *Query) ZCard(key string) *Query

ZCard 返回有序集成员个数 param: key string

func (*Query) ZCount

func (s *Query) ZCount(key string, min, max interface{}) *Query

ZCount 计算有序集合中指定分数区间的成员数量 param: key string param: min interface{} param: max interface{}

func (*Query) ZIncrBy

func (s *Query) ZIncrBy(key string, member, incr interface{}) *Query

ZIncrBy 对有序集合中指定成员的分数加上增量 increment,可以通过传递一个负数值 increment , 让分数减去相应的值,比如 ZINCRBY key -5 member , 就是让 member 的 score 值减去 5 。当 key 不存在,或分数不是 key 的成员时, ZINCRBY key increment member 等同于 ZADD key increment member 。当 key 不是有序集类型时,返回一个错误。分数值可以是整数值或双精度浮点数。 param: key string param: member interface{} 任意类型数据 param: incr interface{} 增量值,可以为整数或双精度浮点

func (*Query) ZPopMax

func (s *Query) ZPopMax(key string, count ...int64) *Query

ZPopMax 移除并弹出有序集合中分值最大的的 count 个元素 redis v5.0.0+ param: key string param: count ...int64 不设置count参数时,弹出一个元素

func (*Query) ZPopMin

func (s *Query) ZPopMin(key string, count ...int64) *Query

ZPopMin 移除并弹出有序集合中分值最小的 count 个元素 redis v5.0.0+ param: key string param: count ...int64 不设置count参数时,弹出一个元素

func (*Query) ZRange

func (s *Query) ZRange(key string, start, stop int, withScore ...bool) *Query

ZRange 返回有序集中,指定区间内的成员。其中成员的位置按分数值递增(从小到大)来排序。 param: key string param: int start, stop 以 0 表示有序集第一个成员,以 1 表示有序集第二个成员,你也可以使用负数下标, param: withScore 是否返回有序集的分数, true - 返回,false - 不返回,默认不返回,结果分开在两个数组存储,但是数组下标是一一对应的,比如 member[3] 成员的分数是 score[3] 以 -1 表示最后一个成员, -2 表示倒数第二个成员,以此类推。

func (*Query) ZRangeByScore

func (s *Query) ZRangeByScore(key string, min, max interface{}, withScores bool, limit ...int64) *Query

ZRangeByScore 根据分数返回有序集中指定区间的成员,顺序从小到大 param: key string param: int min, max 分数的范围,类型必须为 int, float,但是 -inf +inf 表示负正无穷大 param: withScores 是否返回有序集的分数, true - 返回,false - 不返回,默认不返回,结果分开在两个数组存储,但是数组下标是一一对应的,比如 member[3] 成员的分数是 score[3] param: limit offset count 游标

func (*Query) ZRank

func (s *Query) ZRank(key string, member interface{}) *Query

ZRank 返回有序集中指定成员的排名。其中有序集成员按分数值递增(从小到大)顺序排列。 param: key string param: member interface{} 成员,任意类型

func (*Query) ZRem

func (s *Query) ZRem(key string, members ...interface{}) *Query

ZRem 移除有序集中的一个或多个成员,不存在的成员将被忽略。 param: key string param: members ...interface{} 任意类型的多条数据

func (*Query) ZRemRangeByRank

func (s *Query) ZRemRangeByRank(key string, start, stop int) *Query

ZRemRangeByRank 移除有序集中,指定排名(rank)区间内的所有成员。 param: key string param: start stop int 排名区间

func (*Query) ZRemRangeByScore

func (s *Query) ZRemRangeByScore(key string, min, max interface{}) *Query

ZRemRangeByScore 移除有序集中,指定分数(score)区间内的所有成员。 param: key string param: interface{} min max 分数区间,类型为整数或者浮点数

func (*Query) ZRevRange

func (s *Query) ZRevRange(key string, start, stop int, withScore ...bool) *Query

ZRevRange 返回有序集中指定区间的成员,其中成员的位置按分数值递减(从大到小)来排列。 param: key string param: start, stop 排名区间,以 0 表示有序集第一个成员,以 1 表示有序集第二个成员,你也可以使用负数下标, param: withScore 是否返回有序集的分数, true - 返回,false - 不返回,默认不返回,结果分开在两个数组存储,但是数组下标是一一对应的,比如 member[3] 成员的分数是 score[3] 以 -1 表示最后一个成员, -2 表示倒数第二个成员,以此类推。

func (*Query) ZRevRangeByScore

func (s *Query) ZRevRangeByScore(key string, max, min interface{}, withScore bool, limit ...int64) *Query

ZRevRangeByScore 返回有序集中指定分数区间内的所有的成员。有序集成员按分数值递减(从大到小)的次序排列。 param: key string param: max, min interface{} 分数区间,类型为整数或双精度浮点数,但是 -inf +inf 表示负正无穷大 param: withScore 是否返回有序集的分数, true - 返回,false - 不返回,默认不返回,结果分开在两个数组存储,但是数组下标是一一对应的,比如 member[3] 成员的分数是 score[3] param: limit offset count 游标

func (*Query) ZRevRank

func (s *Query) ZRevRank(key string, member interface{}) *Query

ZRevRank 返回有序集中指定成员的排名。其中有序集成员按分数值递增(从大到小)顺序排列。 param: key string param: member interface{} 成员,任意类型

func (*Query) ZScore

func (s *Query) ZScore(key string, member interface{}) *Query

ZScore 返回有序集中,成员的分数值。 param: key string param: member interface{} 成员

type RspErrs

type RspErrs map[string]*Error

RspErrs 所有查询单元的返回码,key 为执行单元 name

func (*RspErrs) Error

func (re *RspErrs) Error(name string) error

Error 根据错误信息返回 error

func (*RspErrs) GetCode

func (re *RspErrs) GetCode(name string) int

GetCode 获取执行单元的返回码

func (*RspErrs) GetMsg

func (re *RspErrs) GetMsg(name string) string

GetMsg 获取执行单元的错误信息

func (*RspErrs) GetType

func (re *RspErrs) GetType(name string) int8

GetType 获取执行单元的错误类型

func (*RspErrs) IsSuccess

func (re *RspErrs) IsSuccess(name string) bool

IsSuccess 执行单元是否成功

type Using

type Using []string

Using sql Join using 结构声明

type Where

type Where map[string]interface{}

Where 查询条件

func (Where) AndWhere

func (w Where) AndWhere(where Where, comment ...string) Where

func (Where) NotWhere

func (w Where) NotWhere(where Where, comment ...string) Where

func (Where) OrWhere

func (w Where) OrWhere(where Where, comment ...string) Where

Directories

Path Synopsis
Package client is horm-go client, including network transportation, resolving, routing etc.
Package client is horm-go client, including network transportation, resolving, routing etc.
pool
Package pool provides the connection pool.
Package pool provides the connection pool.
selector
Package selector determines how database chooses a backend node by service name.
Package selector determines how database chooses a backend node by service name.

Jump to

Keyboard shortcuts

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