dao

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Robot = NewRobotDao()
View Source
var User = NewUserDao()

Functions

func Aggregate

func Aggregate(ctx context.Context, database, collection string, pipeline []bson.M, result interface{}) error

func AggregateByPage

func AggregateByPage(ctx context.Context, database, collection, countField string, paging *db.Paging, countPipeline, pipeline []bson.M, result interface{}) error

func CountDocuments

func CountDocuments(ctx context.Context, database, collection string, filter map[string]interface{}) (int64, error)

func DeleteById

func DeleteById(ctx context.Context, database, collection string, id interface{}) error

func DeleteMany

func DeleteMany(ctx context.Context, database, collection string, filter map[string]interface{}) (int64, error)

func DeleteOne

func DeleteOne(ctx context.Context, database, collection string, filter map[string]interface{}) (int64, error)

func Find

func Find(ctx context.Context, database, collection string, filter map[string]interface{}, result interface{}, sortFields ...string) error

func FindById

func FindById(ctx context.Context, database, collection string, id, result interface{}) error

func FindByIds

func FindByIds(ctx context.Context, database, collection string, ids, result interface{}) error

func FindByPage

func FindByPage(ctx context.Context, database, collection string, paging *db.Paging, filter map[string]interface{}, result interface{}, sortFields ...string) error

func FindOne

func FindOne(ctx context.Context, database, collection string, filter map[string]interface{}, result interface{}, sortFields ...string) error

func Insert

func Insert(ctx context.Context, database string, document interface{}) (string, error)

func Inserts

func Inserts(ctx context.Context, database string, documents []interface{}) ([]string, error)

func UpdateById

func UpdateById(ctx context.Context, database, collection string, id, update interface{}, isUpsert ...bool) error

func UpdateMany

func UpdateMany(ctx context.Context, database, collection string, filter map[string]interface{}, update interface{}, isUpsert ...bool) error

func UpdateOne

func UpdateOne(ctx context.Context, database, collection string, filter map[string]interface{}, update interface{}, isUpsert ...bool) error

Types

type IMongoDB

type IMongoDB interface{}

type MongoDB

type MongoDB[T IMongoDB] struct {
	*db.MongoDB
}

func NewMongoDB

func NewMongoDB[T IMongoDB](database, collection string) *MongoDB[T]

func (*MongoDB[T]) Aggregate

func (m *MongoDB[T]) Aggregate(ctx context.Context, pipeline []bson.M, result interface{}) error

func (*MongoDB[T]) AggregateByPage

func (m *MongoDB[T]) AggregateByPage(ctx context.Context, countField string, paging *db.Paging, countPipeline, pipeline []bson.M, result interface{}) error

func (*MongoDB[T]) CountDocuments

func (m *MongoDB[T]) CountDocuments(ctx context.Context, filter map[string]interface{}) (int64, error)

func (*MongoDB[T]) DeleteById

func (m *MongoDB[T]) DeleteById(ctx context.Context, id interface{}) error

func (*MongoDB[T]) DeleteMany

func (m *MongoDB[T]) DeleteMany(ctx context.Context, filter map[string]interface{}) (int64, error)

func (*MongoDB[T]) DeleteOne

func (m *MongoDB[T]) DeleteOne(ctx context.Context, filter map[string]interface{}) (int64, error)

func (*MongoDB[T]) Find

func (m *MongoDB[T]) Find(ctx context.Context, filter map[string]interface{}, sortFields ...string) ([]*T, error)

func (*MongoDB[T]) FindById

func (m *MongoDB[T]) FindById(ctx context.Context, id interface{}) (*T, error)

func (*MongoDB[T]) FindByIds

func (m *MongoDB[T]) FindByIds(ctx context.Context, ids interface{}) ([]*T, error)

func (*MongoDB[T]) FindByPage

func (m *MongoDB[T]) FindByPage(ctx context.Context, paging *db.Paging, filter map[string]interface{}, sortFields ...string) ([]*T, error)

func (*MongoDB[T]) FindOne

func (m *MongoDB[T]) FindOne(ctx context.Context, filter map[string]interface{}, sortFields ...string) (*T, error)

func (*MongoDB[T]) Insert

func (m *MongoDB[T]) Insert(ctx context.Context, document interface{}) (string, error)

func (*MongoDB[T]) Inserts

func (m *MongoDB[T]) Inserts(ctx context.Context, documents []interface{}) ([]string, error)

func (*MongoDB[T]) UpdateById

func (m *MongoDB[T]) UpdateById(ctx context.Context, id, update interface{}, isUpsert ...bool) error

func (*MongoDB[T]) UpdateMany

func (m *MongoDB[T]) UpdateMany(ctx context.Context, filter map[string]interface{}, update interface{}, isUpsert ...bool) error

func (*MongoDB[T]) UpdateOne

func (m *MongoDB[T]) UpdateOne(ctx context.Context, filter map[string]interface{}, update interface{}, isUpsert ...bool) error

type RobotDao

type RobotDao struct {
	*MongoDB[entity.Robot]
}

func NewRobotDao

func NewRobotDao(database ...string) *RobotDao

func (*RobotDao) GetLoginRobot

func (d *RobotDao) GetLoginRobot(ctx context.Context) (*entity.Robot, error)

获取登录机器的信息

func (*RobotDao) GetRobotByUserId

func (d *RobotDao) GetRobotByUserId(ctx context.Context, userId int) (*entity.Robot, error)

根据绑定userId获取机器人的信息

func (*RobotDao) GetRobotList

func (d *RobotDao) GetRobotList(ctx context.Context, userIds ...int) ([]*entity.Robot, error)

获取机器人列表

func (*RobotDao) GetRobotUserList

func (d *RobotDao) GetRobotUserList(ctx context.Context) ([]*entity.User, error)

获取机器人用户列表

type UserDao

type UserDao struct {
	*MongoDB[entity.User]
}

func NewUserDao

func NewUserDao(database ...string) *UserDao

func (*UserDao) FindUserByUserId

func (d *UserDao) FindUserByUserId(ctx context.Context, userId int) (*entity.User, error)

根据userId查询用户

func (*UserDao) FindUserListByUserIds

func (d *UserDao) FindUserListByUserIds(ctx context.Context, userIds []int) ([]*entity.User, error)

根据userIds查询用户列表

Jump to

Keyboard shortcuts

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