Documentation
¶
Index ¶
- Variables
- func SortFeedbacks(feedback []Feedback)
- type ClickHouseFeedback
- type ClickHouseItem
- type ClickhouseUser
- type Database
- type Feedback
- type FeedbackKey
- type Item
- type ItemPatch
- type MongoDB
- func (db *MongoDB) BatchGetItems(ctx context.Context, itemIds []string) ([]Item, error)
- func (db *MongoDB) BatchInsertFeedback(ctx context.Context, feedback []Feedback, ...) error
- func (db *MongoDB) BatchInsertItems(ctx context.Context, items []Item) error
- func (db *MongoDB) BatchInsertUsers(ctx context.Context, users []User) error
- func (db *MongoDB) Close() error
- func (db *MongoDB) DeleteItem(ctx context.Context, itemId string) error
- func (db *MongoDB) DeleteUser(ctx context.Context, userId string) error
- func (db *MongoDB) DeleteUserItemFeedback(ctx context.Context, userId, itemId string, feedbackTypes ...string) (int, error)
- func (db *MongoDB) GetFeedback(ctx context.Context, cursor string, n int, beginTime, endTime *time.Time, ...) (string, []Feedback, error)
- func (db *MongoDB) GetFeedbackStream(ctx context.Context, batchSize int, beginTime, endTime *time.Time, ...) (chan []Feedback, chan error)
- func (db *MongoDB) GetItem(ctx context.Context, itemId string) (item Item, err error)
- func (db *MongoDB) GetItemFeedback(ctx context.Context, itemId string, feedbackTypes ...string) ([]Feedback, error)
- func (db *MongoDB) GetItemStream(ctx context.Context, batchSize int, timeLimit *time.Time) (chan []Item, chan error)
- func (db *MongoDB) GetItems(ctx context.Context, cursor string, n int, timeLimit *time.Time) (string, []Item, error)
- func (db *MongoDB) GetUser(ctx context.Context, userId string) (user User, err error)
- func (db *MongoDB) GetUserFeedback(ctx context.Context, userId string, endTime *time.Time, ...) ([]Feedback, error)
- func (db *MongoDB) GetUserItemFeedback(ctx context.Context, userId, itemId string, feedbackTypes ...string) ([]Feedback, error)
- func (db *MongoDB) GetUserStream(ctx context.Context, batchSize int) (chan []User, chan error)
- func (db *MongoDB) GetUsers(ctx context.Context, cursor string, n int) (string, []User, error)
- func (db *MongoDB) Init() error
- func (db *MongoDB) ModifyItem(ctx context.Context, itemId string, patch ItemPatch) error
- func (db *MongoDB) ModifyUser(ctx context.Context, userId string, patch UserPatch) error
- func (db *MongoDB) Optimize() error
- func (db *MongoDB) Ping() error
- func (db *MongoDB) Purge() error
- type NoDatabase
- func (NoDatabase) BatchGetItems(_ context.Context, _ []string) ([]Item, error)
- func (NoDatabase) BatchInsertFeedback(_ context.Context, _ []Feedback, _, _, _ bool) error
- func (NoDatabase) BatchInsertItems(_ context.Context, _ []Item) error
- func (NoDatabase) BatchInsertUsers(_ context.Context, _ []User) error
- func (NoDatabase) Close() error
- func (NoDatabase) DeleteItem(_ context.Context, _ string) error
- func (NoDatabase) DeleteUser(_ context.Context, _ string) error
- func (NoDatabase) DeleteUserItemFeedback(_ context.Context, _, _ string, _ ...string) (int, error)
- func (NoDatabase) GetFeedback(_ context.Context, _ string, _ int, _, _ *time.Time, _ ...string) (string, []Feedback, error)
- func (NoDatabase) GetFeedbackStream(_ context.Context, _ int, _, _ *time.Time, _ ...string) (chan []Feedback, chan error)
- func (NoDatabase) GetItem(_ context.Context, _ string) (Item, error)
- func (NoDatabase) GetItemFeedback(_ context.Context, _ string, _ ...string) ([]Feedback, error)
- func (NoDatabase) GetItemStream(_ context.Context, _ int, _ *time.Time) (chan []Item, chan error)
- func (NoDatabase) GetItems(_ context.Context, _ string, _ int, _ *time.Time) (string, []Item, error)
- func (NoDatabase) GetUser(_ context.Context, _ string) (User, error)
- func (NoDatabase) GetUserFeedback(_ context.Context, _ string, _ *time.Time, _ ...string) ([]Feedback, error)
- func (NoDatabase) GetUserItemFeedback(_ context.Context, _, _ string, _ ...string) ([]Feedback, error)
- func (NoDatabase) GetUserStream(_ context.Context, _ int) (chan []User, chan error)
- func (NoDatabase) GetUsers(_ context.Context, _ string, _ int) (string, []User, error)
- func (NoDatabase) Init() error
- func (d NoDatabase) ModifyItem(_ context.Context, _ string, _ ItemPatch) error
- func (d NoDatabase) ModifyUser(_ context.Context, _ string, _ UserPatch) error
- func (NoDatabase) Optimize() error
- func (NoDatabase) Ping() error
- func (NoDatabase) Purge() error
- type Redis
- func (r *Redis) BatchGetItems(ctx context.Context, itemIds []string) ([]Item, error)
- func (r *Redis) BatchInsertFeedback(ctx context.Context, feedback []Feedback, ...) error
- func (r *Redis) BatchInsertItems(ctx context.Context, items []Item) error
- func (r *Redis) BatchInsertUsers(ctx context.Context, users []User) error
- func (r *Redis) Close() error
- func (r *Redis) DeleteItem(ctx context.Context, itemId string) error
- func (r *Redis) DeleteUser(ctx context.Context, userId string) error
- func (r *Redis) DeleteUserItemFeedback(ctx context.Context, userId, itemId string, feedbackTypes ...string) (int, error)
- func (r *Redis) ForFeedback(ctx context.Context, ...) error
- func (r *Redis) GetFeedback(ctx context.Context, _ string, _ int, beginTime, endTime *time.Time, ...) (string, []Feedback, error)
- func (r *Redis) GetFeedbackStream(ctx context.Context, batchSize int, beginTime, endTime *time.Time, ...) (chan []Feedback, chan error)
- func (r *Redis) GetItem(ctx context.Context, itemId string) (Item, error)
- func (r *Redis) GetItemFeedback(ctx context.Context, itemId string, feedbackTypes ...string) ([]Feedback, error)
- func (r *Redis) GetItemStream(ctx context.Context, batchSize int, timeLimit *time.Time) (chan []Item, chan error)
- func (r *Redis) GetItems(ctx context.Context, cursor string, n int, timeLimit *time.Time) (string, []Item, error)
- func (r *Redis) GetUser(ctx context.Context, userId string) (User, error)
- func (r *Redis) GetUserFeedback(ctx context.Context, userId string, endTime *time.Time, ...) ([]Feedback, error)
- func (r *Redis) GetUserItemFeedback(ctx context.Context, userId, itemId string, feedbackTypes ...string) ([]Feedback, error)
- func (r *Redis) GetUserStream(ctx context.Context, batchSize int) (chan []User, chan error)
- func (r *Redis) GetUsers(ctx context.Context, cursor string, n int) (string, []User, error)
- func (r *Redis) Init() error
- func (r *Redis) ModifyItem(ctx context.Context, itemId string, patch ItemPatch) error
- func (r *Redis) ModifyUser(ctx context.Context, userId string, patch UserPatch) error
- func (r *Redis) Optimize() error
- func (r *Redis) Ping() error
- func (r *Redis) Purge() error
- type SQLDatabase
- func (d *SQLDatabase) BatchGetItems(ctx context.Context, itemIds []string) ([]Item, error)
- func (d *SQLDatabase) BatchInsertFeedback(ctx context.Context, feedback []Feedback, ...) error
- func (d *SQLDatabase) BatchInsertItems(ctx context.Context, items []Item) error
- func (d *SQLDatabase) BatchInsertUsers(ctx context.Context, users []User) error
- func (d *SQLDatabase) Close() error
- func (d *SQLDatabase) DeleteItem(ctx context.Context, itemId string) error
- func (d *SQLDatabase) DeleteUser(ctx context.Context, userId string) error
- func (d *SQLDatabase) DeleteUserItemFeedback(ctx context.Context, userId, itemId string, feedbackTypes ...string) (int, error)
- func (d *SQLDatabase) GetFeedback(ctx context.Context, cursor string, n int, beginTime, endTime *time.Time, ...) (string, []Feedback, error)
- func (d *SQLDatabase) GetFeedbackStream(ctx context.Context, batchSize int, beginTime, endTime *time.Time, ...) (chan []Feedback, chan error)
- func (d *SQLDatabase) GetItem(ctx context.Context, itemId string) (Item, error)
- func (d *SQLDatabase) GetItemFeedback(ctx context.Context, itemId string, feedbackTypes ...string) ([]Feedback, error)
- func (d *SQLDatabase) GetItemStream(ctx context.Context, batchSize int, timeLimit *time.Time) (chan []Item, chan error)
- func (d *SQLDatabase) GetItems(ctx context.Context, cursor string, n int, timeLimit *time.Time) (string, []Item, error)
- func (d *SQLDatabase) GetUser(ctx context.Context, userId string) (User, error)
- func (d *SQLDatabase) GetUserFeedback(ctx context.Context, userId string, endTime *time.Time, ...) ([]Feedback, error)
- func (d *SQLDatabase) GetUserItemFeedback(ctx context.Context, userId, itemId string, feedbackTypes ...string) ([]Feedback, error)
- func (d *SQLDatabase) GetUserStream(ctx context.Context, batchSize int) (chan []User, chan error)
- func (d *SQLDatabase) GetUsers(ctx context.Context, cursor string, n int) (string, []User, error)
- func (d *SQLDatabase) Init() error
- func (d *SQLDatabase) ModifyItem(ctx context.Context, itemId string, patch ItemPatch) error
- func (d *SQLDatabase) ModifyUser(ctx context.Context, userId string, patch UserPatch) error
- func (d *SQLDatabase) Optimize() error
- func (d *SQLDatabase) Ping() error
- func (d *SQLDatabase) Purge() error
- type SQLDriver
- type SQLItem
- type SQLUser
- type User
- type UserPatch
Constants ¶
This section is empty.
Variables ¶
var ( ErrUserNotExist = errors.NotFoundf("user") ErrItemNotExist = errors.NotFoundf("item") ErrNoDatabase = errors.NotAssignedf("database") )
Functions ¶
func SortFeedbacks ¶ added in v0.3.1
func SortFeedbacks(feedback []Feedback)
SortFeedbacks sorts feedback from latest to oldest.
Types ¶
type ClickHouseFeedback ¶ added in v0.4.5
type ClickHouseItem ¶ added in v0.4.5
func NewClickHouseItem ¶ added in v0.4.5
func NewClickHouseItem(item Item) (clickHouseItem ClickHouseItem)
type ClickhouseUser ¶ added in v0.4.5
func NewClickhouseUser ¶ added in v0.4.5
func NewClickhouseUser(user User) (clickhouseUser ClickhouseUser)
type Database ¶
type Database interface { Init() error Ping() error Close() error Optimize() error Purge() error BatchInsertItems(ctx context.Context, items []Item) error BatchGetItems(ctx context.Context, itemIds []string) ([]Item, error) DeleteItem(ctx context.Context, itemId string) error GetItem(ctx context.Context, itemId string) (Item, error) ModifyItem(ctx context.Context, itemId string, patch ItemPatch) error GetItems(ctx context.Context, cursor string, n int, beginTime *time.Time) (string, []Item, error) GetItemFeedback(ctx context.Context, itemId string, feedbackTypes ...string) ([]Feedback, error) BatchInsertUsers(ctx context.Context, users []User) error DeleteUser(ctx context.Context, userId string) error GetUser(ctx context.Context, userId string) (User, error) ModifyUser(ctx context.Context, userId string, patch UserPatch) error GetUsers(ctx context.Context, cursor string, n int) (string, []User, error) GetUserFeedback(ctx context.Context, userId string, endTime *time.Time, feedbackTypes ...string) ([]Feedback, error) GetUserItemFeedback(ctx context.Context, userId, itemId string, feedbackTypes ...string) ([]Feedback, error) DeleteUserItemFeedback(ctx context.Context, userId, itemId string, feedbackTypes ...string) (int, error) BatchInsertFeedback(ctx context.Context, feedback []Feedback, insertUser, insertItem, overwrite bool) error GetFeedback(ctx context.Context, cursor string, n int, beginTime, endTime *time.Time, feedbackTypes ...string) (string, []Feedback, error) GetUserStream(ctx context.Context, batchSize int) (chan []User, chan error) GetItemStream(ctx context.Context, batchSize int, timeLimit *time.Time) (chan []Item, chan error) GetFeedbackStream(ctx context.Context, batchSize int, beginTime, endTime *time.Time, feedbackTypes ...string) (chan []Feedback, chan error) }
type Feedback ¶
type Feedback struct { FeedbackKey `gorm:"embedded"` Timestamp time.Time `gorm:"column:time_stamp"` Comment string `gorm:"column:comment"` }
Feedback stores feedback.
type FeedbackKey ¶
type FeedbackKey struct { FeedbackType string `gorm:"column:feedback_type"` UserId string `gorm:"column:user_id"` ItemId string `gorm:"column:item_id"` }
FeedbackKey identifies feedback.
type Item ¶
type Item struct { ItemId string `gorm:"primaryKey"` IsHidden bool Categories []string `gorm:"serializer:json"` Timestamp time.Time Labels []string `gorm:"serializer:json"` Comment string }
Item stores meta data about item.
type ItemPatch ¶ added in v0.2.8
type ItemPatch struct { IsHidden *bool Categories []string Timestamp *time.Time Labels []string Comment *string }
ItemPatch is the modification on an item.
type MongoDB ¶
type MongoDB struct { storage.TablePrefix // contains filtered or unexported fields }
MongoDB is the data storage based on MongoDB.
func (*MongoDB) BatchGetItems ¶ added in v0.4.0
func (*MongoDB) BatchInsertFeedback ¶
func (db *MongoDB) BatchInsertFeedback(ctx context.Context, feedback []Feedback, insertUser, insertItem, overwrite bool) error
BatchInsertFeedback returns multiple feedback into MongoDB.
func (*MongoDB) BatchInsertItems ¶ added in v0.2.6
BatchInsertItems insert items into MongoDB.
func (*MongoDB) BatchInsertUsers ¶ added in v0.2.6
BatchInsertUsers inserts a user into MongoDB.
func (*MongoDB) DeleteItem ¶
DeleteItem deletes a item from MongoDB.
func (*MongoDB) DeleteUser ¶
DeleteUser deletes a user from MongoDB.
func (*MongoDB) DeleteUserItemFeedback ¶
func (db *MongoDB) DeleteUserItemFeedback(ctx context.Context, userId, itemId string, feedbackTypes ...string) (int, error)
DeleteUserItemFeedback deletes a feedback return the user id and item id from MongoDB.
func (*MongoDB) GetFeedback ¶
func (db *MongoDB) GetFeedback(ctx context.Context, cursor string, n int, beginTime, endTime *time.Time, feedbackTypes ...string) (string, []Feedback, error)
GetFeedback returns multiple feedback from MongoDB.
func (*MongoDB) GetFeedbackStream ¶ added in v0.2.6
func (db *MongoDB) GetFeedbackStream(ctx context.Context, batchSize int, beginTime, endTime *time.Time, feedbackTypes ...string) (chan []Feedback, chan error)
GetFeedbackStream reads feedback from MongoDB by stream.
func (*MongoDB) GetItemFeedback ¶
func (db *MongoDB) GetItemFeedback(ctx context.Context, itemId string, feedbackTypes ...string) ([]Feedback, error)
GetItemFeedback returns feedback of a item from MongoDB.
func (*MongoDB) GetItemStream ¶ added in v0.2.6
func (db *MongoDB) GetItemStream(ctx context.Context, batchSize int, timeLimit *time.Time) (chan []Item, chan error)
GetItemStream read items from MongoDB by stream.
func (*MongoDB) GetItems ¶
func (db *MongoDB) GetItems(ctx context.Context, cursor string, n int, timeLimit *time.Time) (string, []Item, error)
GetItems returns items from MongoDB.
func (*MongoDB) GetUserFeedback ¶
func (db *MongoDB) GetUserFeedback(ctx context.Context, userId string, endTime *time.Time, feedbackTypes ...string) ([]Feedback, error)
GetUserFeedback returns feedback of a user from MongoDB.
func (*MongoDB) GetUserItemFeedback ¶
func (db *MongoDB) GetUserItemFeedback(ctx context.Context, userId, itemId string, feedbackTypes ...string) ([]Feedback, error)
GetUserItemFeedback returns a feedback return the user id and item id from MongoDB.
func (*MongoDB) GetUserStream ¶ added in v0.2.6
GetUserStream reads users from MongoDB by stream.
func (*MongoDB) ModifyItem ¶ added in v0.2.8
ModifyItem modify an item in MongoDB.
func (*MongoDB) ModifyUser ¶ added in v0.2.8
ModifyUser modify a user in MongoDB.
type NoDatabase ¶
type NoDatabase struct{}
NoDatabase means that no database used.
func (NoDatabase) BatchGetItems ¶ added in v0.4.0
BatchGetItems method of NoDatabase returns ErrNoDatabase.
func (NoDatabase) BatchInsertFeedback ¶
BatchInsertFeedback method of NoDatabase returns ErrNoDatabase.
func (NoDatabase) BatchInsertItems ¶ added in v0.2.6
func (NoDatabase) BatchInsertItems(_ context.Context, _ []Item) error
BatchInsertItems method of NoDatabase returns ErrNoDatabase.
func (NoDatabase) BatchInsertUsers ¶ added in v0.2.6
func (NoDatabase) BatchInsertUsers(_ context.Context, _ []User) error
BatchInsertUsers method of NoDatabase returns ErrNoDatabase.
func (NoDatabase) Close ¶
func (NoDatabase) Close() error
Close method of NoDatabase returns ErrNoDatabase.
func (NoDatabase) DeleteItem ¶
func (NoDatabase) DeleteItem(_ context.Context, _ string) error
DeleteItem method of NoDatabase returns ErrNoDatabase.
func (NoDatabase) DeleteUser ¶
func (NoDatabase) DeleteUser(_ context.Context, _ string) error
DeleteUser method of NoDatabase returns ErrNoDatabase.
func (NoDatabase) DeleteUserItemFeedback ¶
DeleteUserItemFeedback method of NoDatabase returns ErrNoDatabase.
func (NoDatabase) GetFeedback ¶
func (NoDatabase) GetFeedback(_ context.Context, _ string, _ int, _, _ *time.Time, _ ...string) (string, []Feedback, error)
GetFeedback method of NoDatabase returns ErrNoDatabase.
func (NoDatabase) GetFeedbackStream ¶ added in v0.2.6
func (NoDatabase) GetFeedbackStream(_ context.Context, _ int, _, _ *time.Time, _ ...string) (chan []Feedback, chan error)
GetFeedbackStream method of NoDatabase returns ErrNoDatabase.
func (NoDatabase) GetItemFeedback ¶
GetItemFeedback method of NoDatabase returns ErrNoDatabase.
func (NoDatabase) GetItemStream ¶ added in v0.2.6
GetItemStream method of NoDatabase returns ErrNoDatabase.
func (NoDatabase) GetItems ¶
func (NoDatabase) GetItems(_ context.Context, _ string, _ int, _ *time.Time) (string, []Item, error)
GetItems method of NoDatabase returns ErrNoDatabase.
func (NoDatabase) GetUserFeedback ¶
func (NoDatabase) GetUserFeedback(_ context.Context, _ string, _ *time.Time, _ ...string) ([]Feedback, error)
GetUserFeedback method of NoDatabase returns ErrNoDatabase.
func (NoDatabase) GetUserItemFeedback ¶
func (NoDatabase) GetUserItemFeedback(_ context.Context, _, _ string, _ ...string) ([]Feedback, error)
GetUserItemFeedback method of NoDatabase returns ErrNoDatabase.
func (NoDatabase) GetUserStream ¶ added in v0.2.6
GetUserStream method of NoDatabase returns ErrNoDatabase.
func (NoDatabase) Init ¶
func (NoDatabase) Init() error
Init method of NoDatabase returns ErrNoDatabase.
func (NoDatabase) ModifyItem ¶ added in v0.2.8
func (NoDatabase) ModifyUser ¶ added in v0.2.8
func (NoDatabase) Optimize ¶ added in v0.2.4
func (NoDatabase) Optimize() error
Optimize is used by ClickHouse only.
func (NoDatabase) Ping ¶ added in v0.4.10
func (NoDatabase) Ping() error
func (NoDatabase) Purge ¶ added in v0.4.7
func (NoDatabase) Purge() error
type Redis ¶
type Redis struct {
// contains filtered or unexported fields
}
Redis use Redis as data storage, but used for test only.
func (*Redis) BatchGetItems ¶ added in v0.4.0
func (*Redis) BatchInsertFeedback ¶
func (r *Redis) BatchInsertFeedback(ctx context.Context, feedback []Feedback, insertUser, insertItem, overwrite bool) error
BatchInsertFeedback insert a batch feedback into Redis. If insertUser set, new users will be insert to user table. If insertItem set, new items will be insert to item table.
func (*Redis) BatchInsertItems ¶ added in v0.2.6
BatchInsertItems inserts a batch of items into Redis.
func (*Redis) BatchInsertUsers ¶ added in v0.2.6
BatchInsertUsers inserts a batch pf user into Redis.
func (*Redis) DeleteItem ¶
DeleteItem deletes a item from Redis.
func (*Redis) DeleteUser ¶
DeleteUser deletes a user from Redis.
func (*Redis) DeleteUserItemFeedback ¶
func (r *Redis) DeleteUserItemFeedback(ctx context.Context, userId, itemId string, feedbackTypes ...string) (int, error)
DeleteUserItemFeedback deletes a feedback by user id and item id from Redis.
func (*Redis) ForFeedback ¶
func (*Redis) GetFeedback ¶
func (r *Redis) GetFeedback(ctx context.Context, _ string, _ int, beginTime, endTime *time.Time, feedbackTypes ...string) (string, []Feedback, error)
GetFeedback returns feedback from Redis.
func (*Redis) GetFeedbackStream ¶ added in v0.2.6
func (r *Redis) GetFeedbackStream(ctx context.Context, batchSize int, beginTime, endTime *time.Time, feedbackTypes ...string) (chan []Feedback, chan error)
GetFeedbackStream reads feedback by stream.
func (*Redis) GetItemFeedback ¶
func (r *Redis) GetItemFeedback(ctx context.Context, itemId string, feedbackTypes ...string) ([]Feedback, error)
GetItemFeedback returns feedback of an item from Redis.
func (*Redis) GetItemStream ¶ added in v0.2.6
func (r *Redis) GetItemStream(ctx context.Context, batchSize int, timeLimit *time.Time) (chan []Item, chan error)
GetItemStream read items from Redis by stream.
func (*Redis) GetItems ¶
func (r *Redis) GetItems(ctx context.Context, cursor string, n int, timeLimit *time.Time) (string, []Item, error)
GetItems returns items from Redis.
func (*Redis) GetUserFeedback ¶
func (r *Redis) GetUserFeedback(ctx context.Context, userId string, endTime *time.Time, feedbackTypes ...string) ([]Feedback, error)
GetUserFeedback returns feedback of a user from Redis.
func (*Redis) GetUserItemFeedback ¶
func (r *Redis) GetUserItemFeedback(ctx context.Context, userId, itemId string, feedbackTypes ...string) ([]Feedback, error)
GetUserItemFeedback gets a feedback by user id and item id from Redis.
func (*Redis) GetUserStream ¶ added in v0.2.6
GetUserStream read users from Redis by stream.
func (*Redis) ModifyItem ¶ added in v0.2.8
ModifyItem modify an item in Redis.
func (*Redis) ModifyUser ¶ added in v0.2.8
ModifyUser modify a user in Redis.
type SQLDatabase ¶
type SQLDatabase struct { storage.TablePrefix // contains filtered or unexported fields }
SQLDatabase use MySQL as data storage.
func (*SQLDatabase) BatchGetItems ¶ added in v0.4.0
func (*SQLDatabase) BatchInsertFeedback ¶
func (d *SQLDatabase) BatchInsertFeedback(ctx context.Context, feedback []Feedback, insertUser, insertItem, overwrite bool) error
BatchInsertFeedback insert a batch feedback into MySQL. If insertUser set, new users will be inserted to user table. If insertItem set, new items will be inserted to item table.
func (*SQLDatabase) BatchInsertItems ¶ added in v0.2.6
func (d *SQLDatabase) BatchInsertItems(ctx context.Context, items []Item) error
BatchInsertItems inserts a batch of items into MySQL.
func (*SQLDatabase) BatchInsertUsers ¶ added in v0.2.6
func (d *SQLDatabase) BatchInsertUsers(ctx context.Context, users []User) error
BatchInsertUsers inserts users into MySQL.
func (*SQLDatabase) DeleteItem ¶
func (d *SQLDatabase) DeleteItem(ctx context.Context, itemId string) error
DeleteItem deletes a item from MySQL.
func (*SQLDatabase) DeleteUser ¶
func (d *SQLDatabase) DeleteUser(ctx context.Context, userId string) error
DeleteUser deletes a user from MySQL.
func (*SQLDatabase) DeleteUserItemFeedback ¶
func (d *SQLDatabase) DeleteUserItemFeedback(ctx context.Context, userId, itemId string, feedbackTypes ...string) (int, error)
DeleteUserItemFeedback deletes a feedback by user id and item id from MySQL.
func (*SQLDatabase) GetFeedback ¶
func (d *SQLDatabase) GetFeedback(ctx context.Context, cursor string, n int, beginTime, endTime *time.Time, feedbackTypes ...string) (string, []Feedback, error)
GetFeedback returns feedback from MySQL.
func (*SQLDatabase) GetFeedbackStream ¶ added in v0.2.6
func (d *SQLDatabase) GetFeedbackStream(ctx context.Context, batchSize int, beginTime, endTime *time.Time, feedbackTypes ...string) (chan []Feedback, chan error)
GetFeedbackStream reads feedback by stream.
func (*SQLDatabase) GetItemFeedback ¶
func (d *SQLDatabase) GetItemFeedback(ctx context.Context, itemId string, feedbackTypes ...string) ([]Feedback, error)
GetItemFeedback returns feedback of a item from MySQL.
func (*SQLDatabase) GetItemStream ¶ added in v0.2.6
func (d *SQLDatabase) GetItemStream(ctx context.Context, batchSize int, timeLimit *time.Time) (chan []Item, chan error)
GetItemStream reads items by stream.
func (*SQLDatabase) GetItems ¶
func (d *SQLDatabase) GetItems(ctx context.Context, cursor string, n int, timeLimit *time.Time) (string, []Item, error)
GetItems returns items from MySQL.
func (*SQLDatabase) GetUserFeedback ¶
func (d *SQLDatabase) GetUserFeedback(ctx context.Context, userId string, endTime *time.Time, feedbackTypes ...string) ([]Feedback, error)
GetUserFeedback returns feedback of a user from MySQL.
func (*SQLDatabase) GetUserItemFeedback ¶
func (d *SQLDatabase) GetUserItemFeedback(ctx context.Context, userId, itemId string, feedbackTypes ...string) ([]Feedback, error)
GetUserItemFeedback gets a feedback by user id and item id from MySQL.
func (*SQLDatabase) GetUserStream ¶ added in v0.2.6
GetUserStream read users by stream.
func (*SQLDatabase) ModifyItem ¶ added in v0.2.8
ModifyItem modify an item in MySQL.
func (*SQLDatabase) ModifyUser ¶ added in v0.2.8
ModifyUser modify a user in MySQL.
func (*SQLDatabase) Optimize ¶ added in v0.2.4
func (d *SQLDatabase) Optimize() error
Optimize is used by ClickHouse only.
func (*SQLDatabase) Ping ¶ added in v0.4.10
func (d *SQLDatabase) Ping() error
func (*SQLDatabase) Purge ¶ added in v0.4.7
func (d *SQLDatabase) Purge() error
type SQLItem ¶ added in v0.4.5
type SQLItem struct { ItemId string `gorm:"column:item_id;primaryKey"` IsHidden bool `gorm:"column:is_hidden"` Categories string `gorm:"column:categories"` Timestamp time.Time `gorm:"column:time_stamp"` Labels string `gorm:"column:labels"` Comment string `gorm:"column:comment"` }
func NewSQLItem ¶ added in v0.4.5
type SQLUser ¶ added in v0.4.5
type SQLUser struct { UserId string `gorm:"column:user_id;primaryKey"` Labels string `gorm:"column:labels"` Subscribe string `gorm:"column:subscribe"` Comment string `gorm:"column:comment"` }