Documentation
¶
Index ¶
Constants ¶
const ( COLUMN_CHAT_ID = "chat_id" COLUMN_CREATED_AT = "created_at" COLUMN_ID = "id" COLUMN_MEMO = "memo" COLUMN_METAS = "metas" COLUMN_RECIPIENT_ID = "recipient_id" COLUMN_SENDER_ID = "sender_id" COLUMN_OWNER_ID = "owner_id" COLUMN_SOFT_DELETED_AT = "soft_deleted_at" COLUMN_STATUS = "status" COLUMN_TEXT = "text" COLUMN_TITLE = "title" COLUMN_UPDATED_AT = "updated_at" )
Column names for the chat and message tables
const ( CHAT_STATUS_ACTIVE = "active" CHAT_STATUS_INACTIVE = "inactive" CHAT_STATUS_DELETED = "deleted" CHAT_SYSTEM_ID = "00000000000000000000000000000001" )
Status constants
const ( MESSAGE_STATUS_ACTIVE = "active" MESSAGE_STATUS_INACTIVE = "inactive" MESSAGE_STATUS_DELETED = "deleted" )
Message status constants
const MAX_DATETIME = "9999-12-31 23:59:59"
MAX_DATETIME is a far-future datetime used as the default soft-delete sentinel.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChatInterface ¶
type ChatInterface interface {
IsSoftDeleted() bool
ID() string
SetID(id string) ChatInterface
OwnerID() string
SetOwnerID(id string) ChatInterface
Status() string
SetStatus(status string) ChatInterface
Title() string
SetTitle(title string) ChatInterface
Memo() string
SetMemo(memo string) ChatInterface
Meta(key string) (string, error)
SetMeta(key string, value string) error
Metas() (map[string]string, error)
SetMetas(metas map[string]string) error
UpsertMetas(metas map[string]string) error
CreatedAt() string
CreatedAtCarbon() *carbon.Carbon
SetCreatedAt(createdAt string) ChatInterface
SoftDeletedAt() string
SoftDeletedAtCarbon() *carbon.Carbon
SetSoftDeletedAt(softDeletedAt string) ChatInterface
UpdatedAt() string
UpdatedAtCarbon() *carbon.Carbon
SetUpdatedAt(updatedAt string) ChatInterface
MarkAsNotDirty()
}
ChatInterface defines the interface for a chat record.
func NewChatFromExistingData ¶
func NewChatFromExistingData(data map[string]string) ChatInterface
NewChatFromExistingData creates a new chat from a raw column map (e.g. query results).
type ChatQueryInterface ¶
type ChatQueryInterface interface {
// Validation method
Validate() error
// Count related methods
IsCountOnlySet() bool
GetCountOnly() bool
SetCountOnly(countOnly bool) ChatQueryInterface
// Soft delete related query methods
IsWithSoftDeletedSet() bool
GetWithSoftDeleted() bool
SetWithSoftDeleted(withSoftDeleted bool) ChatQueryInterface
IsOnlySoftDeletedSet() bool
GetOnlySoftDeleted() bool
SetOnlySoftDeleted(onlySoftDeleted bool) ChatQueryInterface
// Field query methods
IsOwnerIDSet() bool
GetOwnerID() string
SetOwnerID(ownerID string) ChatQueryInterface
IsCreatedAtGteSet() bool
GetCreatedAtGte() string
SetCreatedAtGte(createdAt string) ChatQueryInterface
IsCreatedAtLteSet() bool
GetCreatedAtLte() string
SetCreatedAtLte(createdAt string) ChatQueryInterface
IsIDSet() bool
GetID() string
SetID(id string) ChatQueryInterface
IsIDInSet() bool
GetIDIn() []string
SetIDIn(ids []string) ChatQueryInterface
IsLimitSet() bool
GetLimit() int
SetLimit(limit int) ChatQueryInterface
IsOffsetSet() bool
GetOffset() int
SetOffset(offset int) ChatQueryInterface
IsOrderBySet() bool
GetOrderBy() string
SetOrderBy(orderBy string) ChatQueryInterface
IsOrderDirectionSet() bool
GetOrderDirection() string
SetOrderDirection(orderDirection string) ChatQueryInterface
IsStatusSet() bool
GetStatus() string
SetStatus(status string) ChatQueryInterface
IsStatusInSet() bool
GetStatusIn() []string
SetStatusIn(statuses []string) ChatQueryInterface
IsUpdatedAtGteSet() bool
GetUpdatedAtGte() string
SetUpdatedAtGte(updatedAt string) ChatQueryInterface
IsUpdatedAtLteSet() bool
GetUpdatedAtLte() string
SetUpdatedAtLte(updatedAt string) ChatQueryInterface
}
ChatQueryInterface defines the interface for querying chats
func NewChatQuery ¶ added in v1.1.0
func NewChatQuery() ChatQueryInterface
NewChatQuery creates a new chat query
type MessageInterface ¶
type MessageInterface interface {
IsSoftDeleted() bool
ID() string
SetID(id string) MessageInterface
ChatID() string
SetChatID(chatID string) MessageInterface
SenderID() string
SetSenderID(id string) MessageInterface
RecipientID() string
SetRecipientID(id string) MessageInterface
Status() string
SetStatus(status string) MessageInterface
Memo() string
SetMemo(memo string) MessageInterface
Meta(key string) (string, error)
SetMeta(key string, value string) error
Metas() (map[string]string, error)
SetMetas(metas map[string]string) error
UpsertMetas(metas map[string]string) error
Text() string
SetText(text string) MessageInterface
CreatedAt() string
CreatedAtCarbon() *carbon.Carbon
SetCreatedAt(createdAt string) MessageInterface
SoftDeletedAt() string
SoftDeletedAtCarbon() *carbon.Carbon
SetSoftDeletedAt(softDeletedAt string) MessageInterface
UpdatedAt() string
UpdatedAtCarbon() *carbon.Carbon
SetUpdatedAt(updatedAt string) MessageInterface
MarkAsNotDirty()
}
MessageInterface defines the interface for a message record.
func NewMessageFromExistingData ¶
func NewMessageFromExistingData(data map[string]string) MessageInterface
NewMessageFromExistingData creates a new message from a raw column map (e.g. query results).
type MessageQueryInterface ¶
type MessageQueryInterface interface {
// Validation method
Validate() error
// Basic query methods
IsCreatedAtGteSet() bool
GetCreatedAtGte() string
SetCreatedAtGte(createdAt string) MessageQueryInterface
IsCreatedAtLteSet() bool
GetCreatedAtLte() string
SetCreatedAtLte(createdAt string) MessageQueryInterface
IsIDSet() bool
GetID() string
SetID(id string) MessageQueryInterface
IsIDInSet() bool
GetIDIn() []string
SetIDIn(ids []string) MessageQueryInterface
IsIDNotInSet() bool
GetIDNotIn() []string
SetIDNotIn(ids []string) MessageQueryInterface
IsLimitSet() bool
GetLimit() int
SetLimit(limit int) MessageQueryInterface
IsChatIDSet() bool
GetChatID() string
SetChatID(chatID string) MessageQueryInterface
IsChatIDInSet() bool
GetChatIDIn() []string
SetChatIDIn(chatIDs []string) MessageQueryInterface
IsOffsetSet() bool
GetOffset() int
SetOffset(offset int) MessageQueryInterface
IsOrderBySet() bool
GetOrderBy() string
SetOrderBy(orderBy string) MessageQueryInterface
IsOrderDirectionSet() bool
GetOrderDirection() string
SetOrderDirection(orderDirection string) MessageQueryInterface
IsRecipientIDSet() bool
GetRecipientID() string
SetRecipientID(recipientID string) MessageQueryInterface
IsSenderIDSet() bool
GetSenderID() string
SetSenderID(senderID string) MessageQueryInterface
IsStatusSet() bool
GetStatus() string
SetStatus(status string) MessageQueryInterface
IsStatusInSet() bool
GetStatusIn() []string
SetStatusIn(statuses []string) MessageQueryInterface
// Count related methods
IsCountOnlySet() bool
GetCountOnly() bool
SetCountOnly(countOnly bool) MessageQueryInterface
// Soft delete related query methods
IsWithSoftDeletedSet() bool
GetWithSoftDeleted() bool
SetWithSoftDeleted(withSoftDeleted bool) MessageQueryInterface
IsOnlySoftDeletedSet() bool
GetOnlySoftDeleted() bool
SetOnlySoftDeleted(onlySoftDeleted bool) MessageQueryInterface
}
MessageQueryInterface defines the interface for querying messages
func MessageQuery ¶
func MessageQuery() MessageQueryInterface
MessageQuery creates a new message query
func NewMessageQuery ¶ added in v1.1.0
func NewMessageQuery() MessageQueryInterface
NewMessageQuery creates a new message query
type NewStoreOptions ¶
type NewStoreOptions struct {
TableChatName string
TableMessageName string
DB *sql.DB
AutomigrateEnabled bool
DebugEnabled bool
Logger *slog.Logger
}
NewStoreOptions defines the options for creating a new chat store.
type StoreInterface ¶
type StoreInterface interface {
// GetChatTableName returns the chat table name
GetChatTableName() string
// SetChatTableName sets the chat table name
SetChatTableName(tableName string)
// GetMessageTableName returns the message table name
GetMessageTableName() string
// SetMessageTableName sets the message table name
SetMessageTableName(tableName string)
// MigrateDown drops the chat and message tables
MigrateDown(ctx context.Context, tx ...*sql.Tx) error
// MigrateUp creates the chat and message tables
MigrateUp(ctx context.Context, tx ...*sql.Tx) error
EnableDebug(enabled bool)
ChatCount(options ChatQueryInterface) (int64, error)
ChatCreate(chat ChatInterface) error
ChatDelete(chat ChatInterface) error
ChatDeleteByID(id string) error
ChatFindByID(id string) (ChatInterface, error)
ChatList(options ChatQueryInterface) ([]ChatInterface, error)
ChatSoftDelete(chat ChatInterface) error
ChatSoftDeleteByID(id string) error
ChatUpdate(chat ChatInterface) error
MessageCount(options MessageQueryInterface) (int64, error)
MessageCreate(message MessageInterface) error
MessageDelete(message MessageInterface) error
MessageDeleteByID(id string) error
MessageFindByID(id string) (MessageInterface, error)
MessageList(options MessageQueryInterface) ([]MessageInterface, error)
MessageSoftDelete(message MessageInterface) error
MessageSoftDeleteByID(id string) error
MessageUpdate(message MessageInterface) error
}
func NewStore ¶
func NewStore(opts NewStoreOptions) (StoreInterface, error)
NewStore creates a new chat store.