db

package
v0.0.0-...-7c02c66 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2023 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBatchAlreadyClosed = errors.New("batch already closed")
)

Functions

func NewPostgresWithOpt

func NewPostgresWithOpt(opts ...pgConnOpt) *postgresClientOpt

func WithDbName

func WithDbName(dbName string) pgConnOpt

func WithHost

func WithHost(host string) pgConnOpt

func WithMaxConns

func WithMaxConns(maxConns int32) pgConnOpt

func WithMinConns

func WithMinConns(minConns int32) pgConnOpt

func WithPassword

func WithPassword(password string) pgConnOpt

func WithPort

func WithPort(port uint16) pgConnOpt

func WithUsername

func WithUsername(username string) pgConnOpt

Types

type ArchiveConversationsBatchResults

type ArchiveConversationsBatchResults struct {
	// contains filtered or unexported fields
}

func (*ArchiveConversationsBatchResults) Close

func (*ArchiveConversationsBatchResults) Exec

func (b *ArchiveConversationsBatchResults) Exec(f func(int, error))

type CheckJoinedonversationParams

type CheckJoinedonversationParams struct {
	SessionID      string
	ConversationID string
}

type Conversation

type Conversation struct {
	ConversationID   string
	LastMsgID        *string
	LastSendTime     pgtype.Timestamp
	IsDelete         bool
	ConversationType int64
	LastSendSession  *string
	IsArchive        bool
}

type ConversationSessionID

type ConversationSessionID struct {
	ID             int32
	SessionID      string
	LastRecvMsgID  *string
	IsKickOut      bool
	ConversationID string
}

type CreateConversationParams

type CreateConversationParams struct {
	ConversationID   string
	ConversationType int64
}

type DBTX

type DBTX interface {
	Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
	Query(context.Context, string, ...interface{}) (pgx.Rows, error)
	QueryRow(context.Context, string, ...interface{}) pgx.Row
	CopyFrom(ctx context.Context, tableName pgx.Identifier, columnNames []string, rowSrc pgx.CopyFromSource) (int64, error)
	SendBatch(context.Context, *pgx.Batch) pgx.BatchResults
}

type DeleteConversationsBatchResults

type DeleteConversationsBatchResults struct {
	// contains filtered or unexported fields
}

func (*DeleteConversationsBatchResults) Close

func (*DeleteConversationsBatchResults) Exec

func (b *DeleteConversationsBatchResults) Exec(f func(int, error))

type GetConversationUnReadMsgCountParams

type GetConversationUnReadMsgCountParams struct {
	ConversationID string
	LastRecvMsgID  string
	LastSendMsgID  string
}

type GetJoinedConversationsRow

type GetJoinedConversationsRow struct {
	ID             int32
	SessionID      string
	LastRecvMsgID  *string
	IsKickOut      bool
	ConversationID string
	Unread         int32
}

type GetJoinedConversationsUnReadMsgCountParams

type GetJoinedConversationsUnReadMsgCountParams struct {
	LastRecvMsgID string
	LastSendMsgID string
}

type GetMsgFromDbInRangeParams

type GetMsgFromDbInRangeParams struct {
	ConversationID string
	StartMsgID     string
	EndMsgID       string
}

type GetThe30MsgAfterTheIdParams

type GetThe30MsgAfterTheIdParams struct {
	ConversationID string
	MsgID          string
}

type GetThe30MsgBeforeTheIdParams

type GetThe30MsgBeforeTheIdParams struct {
	ConversationID string
	MsgID          string
}

type KickoutForConversationBatchResults

type KickoutForConversationBatchResults struct {
	// contains filtered or unexported fields
}

func (*KickoutForConversationBatchResults) Close

func (*KickoutForConversationBatchResults) Exec

func (b *KickoutForConversationBatchResults) Exec(f func(int, error))

type KickoutForConversationParams

type KickoutForConversationParams struct {
	SessionID      string
	ConversationID string
}

type Message

type Message struct {
	MsgID          string
	ConversationID string
	FromSession    int32
	SendTime       jtime.Time
	Status         int32
	Type           int32
	Content        *string
}

type Queries

type Queries struct {
	// contains filtered or unexported fields
}

func New

func New(db DBTX) *Queries

func (*Queries) ArchiveConversations

func (q *Queries) ArchiveConversations(ctx context.Context, conversationID []string) *ArchiveConversationsBatchResults

func (*Queries) CheckJoinedonversation

func (q *Queries) CheckJoinedonversation(ctx context.Context, arg CheckJoinedonversationParams) (int64, error)

func (*Queries) CreateConversation

func (q *Queries) CreateConversation(ctx context.Context, arg CreateConversationParams) error

func (*Queries) DeleteConversations

func (q *Queries) DeleteConversations(ctx context.Context, conversationID []string) *DeleteConversationsBatchResults

func (*Queries) GetConversationInfo

func (q *Queries) GetConversationInfo(ctx context.Context, conversationID string) (Conversation, error)

func (*Queries) GetConversationSessionCountByConversationPkId

func (q *Queries) GetConversationSessionCountByConversationPkId(ctx context.Context, conversationID string) (int64, error)

func (*Queries) GetConversationUnReadMsgCount

func (q *Queries) GetConversationUnReadMsgCount(ctx context.Context, arg GetConversationUnReadMsgCountParams) (int64, error)

func (*Queries) GetConversationsAllUsers

func (q *Queries) GetConversationsAllUsers(ctx context.Context) ([]ConversationSessionID, error)

func (*Queries) GetJoinedConversations

func (q *Queries) GetJoinedConversations(ctx context.Context, sessionID string) ([]GetJoinedConversationsRow, error)

func (*Queries) GetJoinedConversationsUnReadMsgCount

func (q *Queries) GetJoinedConversationsUnReadMsgCount(ctx context.Context, arg GetJoinedConversationsUnReadMsgCountParams) (int64, error)

func (*Queries) GetLast30MsgFromDb

func (q *Queries) GetLast30MsgFromDb(ctx context.Context, conversationID string) ([]Message, error)

func (*Queries) GetLastOneMsgIdFromDb

func (q *Queries) GetLastOneMsgIdFromDb(ctx context.Context, conversationID string) (*string, error)

func (*Queries) GetMsgFromDbInRange

func (q *Queries) GetMsgFromDbInRange(ctx context.Context, arg GetMsgFromDbInRangeParams) ([]Message, error)

func (*Queries) GetThe30MsgAfterTheId

func (q *Queries) GetThe30MsgAfterTheId(ctx context.Context, arg GetThe30MsgAfterTheIdParams) ([]Message, error)

func (*Queries) GetThe30MsgBeforeTheId

func (q *Queries) GetThe30MsgBeforeTheId(ctx context.Context, arg GetThe30MsgBeforeTheIdParams) ([]Message, error)

func (*Queries) SaveMsgToDb

func (q *Queries) SaveMsgToDb(ctx context.Context, arg []SaveMsgToDbParams) *SaveMsgToDbBatchResults

func (*Queries) SessionJoinsConversationUseCopyFrom

func (q *Queries) SessionJoinsConversationUseCopyFrom(ctx context.Context, arg []SessionJoinsConversationUseCopyFromParams) (int64, error)

func (*Queries) UnArchiveConversations

func (q *Queries) UnArchiveConversations(ctx context.Context, conversationID []string) *UnArchiveConversationsBatchResults

func (*Queries) UpdateConversationLastMsg

func (q *Queries) UpdateConversationLastMsg(ctx context.Context, arg UpdateConversationLastMsgParams) error

func (*Queries) UpdateSessionLastRecvMsg

func (q *Queries) UpdateSessionLastRecvMsg(ctx context.Context, arg UpdateSessionLastRecvMsgParams) error

func (*Queries) WithTx

func (q *Queries) WithTx(tx pgx.Tx) *Queries

type SaveMsgToDbBatchResults

type SaveMsgToDbBatchResults struct {
	// contains filtered or unexported fields
}

func (*SaveMsgToDbBatchResults) Close

func (b *SaveMsgToDbBatchResults) Close() error

func (*SaveMsgToDbBatchResults) Exec

func (b *SaveMsgToDbBatchResults) Exec(f func(int, error))

type SaveMsgToDbParams

type SaveMsgToDbParams struct {
	MsgID          string
	ConversationID string
	FromSession    int32
	SendTime       jtime.Time
	Status         int32
	Type           int32
	Content        *string
}

type Session

type Session struct {
	ID      int32
	Session string
}

type SessionJoinsConversationUseCopyFromParams

type SessionJoinsConversationUseCopyFromParams struct {
	SessionID      string
	ConversationID string
}

type UnArchiveConversationsBatchResults

type UnArchiveConversationsBatchResults struct {
	// contains filtered or unexported fields
}

func (*UnArchiveConversationsBatchResults) Close

func (*UnArchiveConversationsBatchResults) Exec

func (b *UnArchiveConversationsBatchResults) Exec(f func(int, error))

type UpdateConversationLastMsgParams

type UpdateConversationLastMsgParams struct {
	LastSendTime    pgtype.Timestamp
	LastMsgID       string
	LastSendSession string
	ConversationID  string
}

type UpdateSessionLastRecvMsgParams

type UpdateSessionLastRecvMsgParams struct {
	LastMsgID      string
	ConversationID string
	SessionID      string
}

Jump to

Keyboard shortcuts

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