Documentation ¶
Index ¶
- type Config
- type DBInterface
- type DataOperation
- type Etcd
- func (e *Etcd) Connect(ctx context.Context) error
- func (e *Etcd) Delete(ctx context.Context, key string) error
- func (e *Etcd) Disconnect(ctx context.Context) error
- func (e *Etcd) Get(ctx context.Context, key string) (string, error)
- func (e *Etcd) IsConnected() bool
- func (e *Etcd) Ping(ctx context.Context) error
- func (e *Etcd) Put(ctx context.Context, key, value string) error
- func (e *Etcd) Reconnect(ctx context.Context) error
- func (e *Etcd) Watch(ctx context.Context, key string) clientv3.WatchChan
- type MongoDB
- func (m *MongoDB) Connect(ctx context.Context) error
- func (m *MongoDB) Create(ctx context.Context, collection string, data interface{}) error
- func (m *MongoDB) Delete(ctx context.Context, collection string, filter interface{}) error
- func (m *MongoDB) Disconnect(ctx context.Context) error
- func (m *MongoDB) IsConnected() bool
- func (m *MongoDB) List(ctx context.Context, collection string, filter interface{}, ...) error
- func (m *MongoDB) Ping(ctx context.Context) error
- func (m *MongoDB) Read(ctx context.Context, collection string, filter interface{}, result interface{}) error
- func (m *MongoDB) Reconnect(ctx context.Context) error
- func (m *MongoDB) Update(ctx context.Context, collection string, filter interface{}, update interface{}) error
- type PostgreSQL
- func (p *PostgreSQL) Connect(ctx context.Context) error
- func (p *PostgreSQL) Create(ctx context.Context, table string, data interface{}) error
- func (p *PostgreSQL) Delete(ctx context.Context, table string, filter interface{}) error
- func (p *PostgreSQL) Disconnect(ctx context.Context) error
- func (p *PostgreSQL) IsConnected() bool
- func (p *PostgreSQL) List(ctx context.Context, table string, filter interface{}, results interface{}) error
- func (p *PostgreSQL) Ping(ctx context.Context) error
- func (p *PostgreSQL) Read(ctx context.Context, table string, filter interface{}, result interface{}) error
- func (p *PostgreSQL) Reconnect(ctx context.Context) error
- func (p *PostgreSQL) Update(ctx context.Context, table string, filter interface{}, update interface{}) error
- type Redis
- func (r *Redis) Connect(ctx context.Context) error
- func (r *Redis) Delete(ctx context.Context, key string) error
- func (r *Redis) Disconnect(ctx context.Context) error
- func (r *Redis) Exists(ctx context.Context, key string) (bool, error)
- func (r *Redis) Get(ctx context.Context, key string) (string, error)
- func (r *Redis) IsConnected() bool
- func (r *Redis) Ping(ctx context.Context) error
- func (r *Redis) Reconnect(ctx context.Context) error
- func (r *Redis) Set(ctx context.Context, key string, value interface{}, expiration time.Duration) error
- type SQLServer
- func (s *SQLServer) Connect(ctx context.Context) error
- func (s *SQLServer) Create(ctx context.Context, table string, data map[string]interface{}) error
- func (s *SQLServer) Delete(ctx context.Context, table string, filter map[string]interface{}) error
- func (s *SQLServer) Disconnect(ctx context.Context) error
- func (s *SQLServer) IsConnected() bool
- func (s *SQLServer) List(ctx context.Context, table string, filter map[string]interface{}, ...) error
- func (s *SQLServer) Ping(ctx context.Context) error
- func (s *SQLServer) Read(ctx context.Context, table string, filter map[string]interface{}, ...) error
- func (s *SQLServer) Reconnect(ctx context.Context) error
- func (s *SQLServer) Update(ctx context.Context, table string, filter map[string]interface{}, ...) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { Host string Port int Username string Password string Database string Options map[string]interface{} }
Config 数据库配置结构
type DBInterface ¶
type DBInterface interface { Connect(ctx context.Context) error Disconnect(ctx context.Context) error Ping(ctx context.Context) error IsConnected() bool Reconnect(ctx context.Context) error }
DBInterface 定义所有数据库操作的通用接口
type DataOperation ¶
type DataOperation interface { Create(ctx context.Context, collection string, data interface{}) error Read(ctx context.Context, collection string, filter interface{}, result interface{}) error Update(ctx context.Context, collection string, filter interface{}, update interface{}) error Delete(ctx context.Context, collection string, filter interface{}) error List(ctx context.Context, collection string, filter interface{}, results interface{}) error }
DataOperation 定义基础的数据操作接口
type Etcd ¶
type Etcd struct {
// contains filtered or unexported fields
}
func (*Etcd) IsConnected ¶
type MongoDB ¶
type MongoDB struct {
// contains filtered or unexported fields
}
func NewMongoDB ¶
func (*MongoDB) IsConnected ¶
type PostgreSQL ¶
type PostgreSQL struct {
// contains filtered or unexported fields
}
func NewPostgreSQL ¶
func NewPostgreSQL(config *Config) *PostgreSQL
func (*PostgreSQL) Create ¶
func (p *PostgreSQL) Create(ctx context.Context, table string, data interface{}) error
CRUD operations
func (*PostgreSQL) Delete ¶
func (p *PostgreSQL) Delete(ctx context.Context, table string, filter interface{}) error
func (*PostgreSQL) Disconnect ¶
func (p *PostgreSQL) Disconnect(ctx context.Context) error
func (*PostgreSQL) IsConnected ¶
func (p *PostgreSQL) IsConnected() bool
func (*PostgreSQL) List ¶
func (p *PostgreSQL) List(ctx context.Context, table string, filter interface{}, results interface{}) error
type Redis ¶
type Redis struct {
// contains filtered or unexported fields
}
func (*Redis) IsConnected ¶
Click to show internal directories.
Click to hide internal directories.