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: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Contact = NewContactDao()
View Source
var Group = NewGroupDao()
View Source
var GroupMember = NewGroupMemberDao()
View Source
var Robot = NewRobotDao()
View Source
var Sequence = NewSequenceDao()
View Source
var TalkRecords = NewTalkRecordsDao()
View Source
var TalkRecordsVote = NewTalkRecordsVoteDao()
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 ContactDao

type ContactDao struct {
	*MongoDB[entity.Contact]
}

func NewContactDao

func NewContactDao(database ...string) *ContactDao

func (*ContactDao) GetContactIds

func (d *ContactDao) GetContactIds(ctx context.Context, uid int) []int

type GroupDao

type GroupDao struct {
	*MongoDB[entity.Group]
}

func NewGroupDao

func NewGroupDao(database ...string) *GroupDao

func (*GroupDao) FindGroupByGroupId

func (d *GroupDao) FindGroupByGroupId(ctx context.Context, groupId int) (*entity.Group, error)

根据groupId查询群信息

type GroupMemberDao

type GroupMemberDao struct {
	*MongoDB[entity.GroupMember]
}

func NewGroupMemberDao

func NewGroupMemberDao(database ...string) *GroupMemberDao

func (*GroupMemberDao) GetMemberIds

func (d *GroupMemberDao) GetMemberIds(ctx context.Context, groupId int) []int

获取所有群成员用户ID

func (*GroupMemberDao) GetUserGroupIds

func (d *GroupMemberDao) GetUserGroupIds(ctx context.Context, uid int) []int

获取所有群成员ID

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 SequenceDao

type SequenceDao struct {
	*MongoDB[entity.TalkRecords]
	// contains filtered or unexported fields
}

func NewSequenceDao

func NewSequenceDao(database ...string) *SequenceDao

func (*SequenceDao) BatchGet

func (d *SequenceDao) BatchGet(ctx context.Context, userId int, receiverId int, num int64) []int64

批量获取会话间的时序ID

func (*SequenceDao) Get

func (d *SequenceDao) Get(ctx context.Context, userId int, receiverId int) int64

获取会话间的时序ID

type TalkRecordsDao

type TalkRecordsDao struct {
	*MongoDB[entity.TalkRecords]
}

func NewTalkRecordsDao

func NewTalkRecordsDao(database ...string) *TalkRecordsDao

func (*TalkRecordsDao) FindByRecordId

func (d *TalkRecordsDao) FindByRecordId(ctx context.Context, recordId int) (*entity.TalkRecords, error)

func (*TalkRecordsDao) GetTalkRecord

func (d *TalkRecordsDao) GetTalkRecord(ctx context.Context, recordId int) (*entity.TalkRecords, *entity.User, error)

获取对话消息

func (*TalkRecordsDao) HandleTalkRecords

func (d *TalkRecordsDao) HandleTalkRecords(ctx context.Context, items []*model.TalkRecordsItem) ([]*model.TalkRecordsItem, error)

type TalkRecordsVoteDao

type TalkRecordsVoteDao struct {
	*MongoDB[entity.TalkRecordsVote]
	// contains filtered or unexported fields
}

func NewTalkRecordsVoteDao

func NewTalkRecordsVoteDao(database ...string) *TalkRecordsVoteDao

func (*TalkRecordsVoteDao) GetVoteAnswerUser

func (d *TalkRecordsVoteDao) GetVoteAnswerUser(ctx context.Context, vid string) ([]int, error)

func (*TalkRecordsVoteDao) GetVoteStatistics

func (d *TalkRecordsVoteDao) GetVoteStatistics(ctx context.Context, vid string) (*model.VoteStatistics, error)

func (*TalkRecordsVoteDao) SetVoteAnswerUser

func (d *TalkRecordsVoteDao) SetVoteAnswerUser(ctx context.Context, vid string) ([]int, error)

func (*TalkRecordsVoteDao) SetVoteStatistics

func (d *TalkRecordsVoteDao) SetVoteStatistics(ctx context.Context, vid string) (*model.VoteStatistics, 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