datastore

package
v0.0.0-...-4fdfd55 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2019 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoAnonymousAliasLeft = errors.New("no anonymous aliases left")

ErrNoAnonymousAliasLeft is used when all anonymous aliases have been assigned to individual users.

View Source
var ErrUserNotFound = errors.New("user not found")

Functions

func DropDatabase

func DropDatabase(c Config) error

DropDatabase deletes the existing database.

func SetupDatabase

func SetupDatabase(c Config) error

Types

type CardComment

type CardComment struct {
	ByName         string      `db:"by_name"`
	ImagePath      string      `db:"image_path"`
	IsAnonymous    bool        `db:"is_anonymous"`
	Timestamp      time.Time   `db:"created_at"`
	AuthorUsername string      `db:"author_username"`
	AuthorID       globalid.ID `db:"id"`
}

func (*CardComment) DisplayName

func (cc *CardComment) DisplayName() string

type CardLike

type CardLike struct {
	ByName      string    `db:"by_name"`
	ImagePath   string    `db:"image_path"`
	IsAnonymous bool      `db:"is_anonymous"`
	Timestamp   time.Time `db:"created_at"`
}

func (*CardLike) DisplayName

func (cc *CardLike) DisplayName() string

type CommentNotificationExportData

type CommentNotificationExportData struct {
	Comments              []*CardComment `db:"-"`
	RootOwnerID           globalid.ID    `db:"owner_id"`
	RootIsAnonymous       bool           `db:"root_is_anon"`
	PosterName            string         `db:"display_name"`
	PosterImage           string         `db:"profile_image_path"`
	CardContent           string         `db:"content"`
	ThreadRootID          globalid.ID    `db:"thread_root_id"`
	LatestCommentID       globalid.ID    `db:"latest_comment_id"`
	LatestCommentParentID globalid.ID    `db:"latest_comment_parent_id"`
}

type Config

type Config struct {
	Database           string   `toml:"database"`
	Host               string   `toml:"host"`
	Port               int      `toml:"port"`
	User               string   `toml:"user"`
	Password           string   `toml:"password"`
	MigrationPath      string   `toml:"migrationPath"`
	Environment        string   `toml:"environment"`
	MaxConnections     int      `toml:"maxConnections"`
	ImageHost          string   `toml:"imageHost"`
	AnonymousIconsPath string   `toml:"anonymousIconsPath"`
	Tags               []string `toml:"tags"`
}

Config provides the configuration required by the store package.

func NewConfig

func NewConfig() Config

NewConfig returns a new instance of Config.

func NewTestConfig

func NewTestConfig() Config

NewTestConfig returns a config used for testing

func (Config) Validate

func (c Config) Validate() error

Validate returns an error if the config is invalid.

type FollowNotificationExportData

type FollowNotificationExportData struct {
	Followers []*Follower `db:"-"`
}

type Follower

type Follower struct {
	ID        globalid.ID `db:"id"`
	Username  string      `db:"username"`
	Name      string      `db:"display_name"`
	ImagePath string      `db:"profile_image_path"`
	Timestamp time.Time   `db:"created_at"`
}

func (*Follower) DisplayName

func (f *Follower) DisplayName() string

type LeaderboardNotificationExportData

type LeaderboardNotificationExportData struct {
	NotificationID globalid.ID `db:"notification_id"`
	Rank           int64       `db:"rank"`
}

type LikeNotificationExportData

type LikeNotificationExportData struct {
	Boosts         []*CardLike `db:"-"`
	IsComment      bool        `db:"is_comment"`
	PosterImage    string      `db:"profile_image_path"`
	CardContent    string      `db:"content"`
	ThreadRootID   globalid.ID `db:"thread_root_id"`
	ThreadReplyID  globalid.ID `db:"thread_reply_id"`
	AuthorUsername string      `db:"username"`
}

type MentionNotificationExportData

type MentionNotificationExportData struct {
	Name                 string      `db:"name"`
	IsAnonymous          bool        `db:"is_anon"`
	ImagePath            string      `db:"image_path"`
	InComment            bool        `db:"in_comment"`
	ThreadRoot           globalid.ID `db:"thread_root_id"`
	ThreadReply          globalid.ID `db:"thread_reply_id"`
	InCard               globalid.ID `db:"in_card"`
	InCardAuthorUsername string      `db:"username"`
}

type PopularPostNotificationExportData

type PopularPostNotificationExportData struct {
	ThreadRootID        globalid.ID `db:"thread_root_id"`
	CommentCardID       globalid.ID `db:"comment_card_id"`
	CommentCardUsername string      `db:"comment_card_username"`
	ParentCommentID     globalid.ID `db:"parent_comment_id"`
}

type Store

type Store struct {
	*sqlx.DB
	// contains filtered or unexported fields
}

func New

func New(c Config) (*Store, error)

New returns a new instance of Store. It connects to the default database postgres to check whether the application database exists. If it does not, it creates the database and uses the current schema.

func (*Store) AddAllUsersToChannel

func (store *Store) AddAllUsersToChannel(channelID globalid.ID) error

AddUserToDefaultChannels stop

func (*Store) AddCardsToTopOfFeed

func (store *Store) AddCardsToTopOfFeed(userID globalid.ID, cardRankedIDs []globalid.ID) error

func (*Store) AddCoinsToBalance

func (store *Store) AddCoinsToBalance(userID globalid.ID, amount int) error

func (*Store) AddToCoinsEarned

func (store *Store) AddToCoinsEarned(cardID globalid.ID, amount int) error

func (*Store) AddUserToDefaultChannels

func (store *Store) AddUserToDefaultChannels(userID globalid.ID) error

AddUserToDefaultChannels stop

func (*Store) AssignAliasForUserTipsInThread

func (store *Store) AssignAliasForUserTipsInThread(userID, threadRootID, aliasID globalid.ID) error

func (*Store) AwardCoins

func (store *Store) AwardCoins(userID globalid.ID, amount int64) error

func (*Store) AwardTemporaryCoins

func (store *Store) AwardTemporaryCoins(userID globalid.ID, amount int64) error

func (*Store) BatchGetLastActiveAt

func (store *Store) BatchGetLastActiveAt(ids []globalid.ID) ([]*model.DBTime, error)

func (*Store) BlockAnonUserInThread

func (store *Store) BlockAnonUserInThread(blockingUser, blockedAlias, threadID globalid.ID) error

func (*Store) BlockUser

func (store *Store) BlockUser(blockingUser, blockedUser globalid.ID) error

func (*Store) BuildInitialFeed

func (store *Store) BuildInitialFeed(userID globalid.ID) error

func (*Store) ChangeFeatureSwitchState

func (store *Store) ChangeFeatureSwitchState(featureID globalid.ID, state string) error

GetSavedLink returns the saved link for the provided ID

func (*Store) ClearEmptyNotifications

func (store *Store) ClearEmptyNotifications() error

func (*Store) ClearEmptyNotificationsForUser

func (store *Store) ClearEmptyNotificationsForUser(userID globalid.ID) error

func (*Store) ClearLeaderboardRankings

func (store *Store) ClearLeaderboardRankings() error

func (*Store) Close

func (store *Store) Close() error

func (*Store) CountCardsInFeed

func (store *Store) CountCardsInFeed(userID globalid.ID) (int64, error)

func (*Store) CountCardsWithNoReactions

func (store *Store) CountCardsWithNoReactions() (int, error)

func (*Store) CountPostsByAliasInThread

func (store *Store) CountPostsByAliasInThread(aliasID, threadRootID globalid.ID) (int, error)

func (*Store) CreateAnonymousAliases

func (store *Store) CreateAnonymousAliases() error

CreateAnonymousAliases will update an existing user or create a new user record in the datastore.

func (*Store) DeleteAllCardsForUser

func (store *Store) DeleteAllCardsForUser(userID globalid.ID) error

func (*Store) DeleteAnnouncement

func (store *Store) DeleteAnnouncement(id globalid.ID) error

func (*Store) DeleteCard

func (store *Store) DeleteCard(id globalid.ID) error

func (*Store) DeleteCardFromFeeds

func (store *Store) DeleteCardFromFeeds(cardID globalid.ID) error

func (*Store) DeleteExpiredSessions

func (store *Store) DeleteExpiredSessions() (int64, error)

func (*Store) DeleteFollower

func (store *Store) DeleteFollower(followerID, followeeID globalid.ID) error

func (*Store) DeleteInvite

func (store *Store) DeleteInvite(id globalid.ID) error

DeleteInvite deletes the invite with the provided ID

func (*Store) DeleteMentionsForCard

func (store *Store) DeleteMentionsForCard(cardID globalid.ID) error

func (*Store) DeleteNotification

func (store *Store) DeleteNotification(id globalid.ID) error

func (*Store) DeleteNotificationsForCard

func (store *Store) DeleteNotificationsForCard(cardID globalid.ID) error

func (*Store) DeleteReactionForNotification

func (store *Store) DeleteReactionForNotification(notifID, userID, cardID globalid.ID) error

func (*Store) DeleteSession

func (store *Store) DeleteSession(id globalid.ID) error

func (*Store) DeleteSessionsForUser

func (store *Store) DeleteSessionsForUser(userID globalid.ID) error

func (*Store) DeleteSwitch

func (store *Store) DeleteSwitch(id globalid.ID) error

GetSavedLink returns the saved link for the provided ID

func (*Store) DeleteUser

func (store *Store) DeleteUser(id globalid.ID) error

func (*Store) DeleteUserReaction

func (store *Store) DeleteUserReaction(userID, cardID globalid.ID) error

func (*Store) DeleteUserReactionForType

func (store *Store) DeleteUserReactionForType(userID, cardID globalid.ID, typ model.UserReactionType) (int64, error)

func (*Store) DeleteWaitlistEntry

func (store *Store) DeleteWaitlistEntry(email string) error

func (*Store) FeaturedCommentsForUser

func (store *Store) FeaturedCommentsForUser(userID, cardID globalid.ID) ([]*model.Card, error)

func (*Store) FeaturedCommentsForUserByCardIDs

func (store *Store) FeaturedCommentsForUserByCardIDs(userID globalid.ID, cardIDs []globalid.ID) (map[globalid.ID]*model.Card, error)

func (*Store) FollowDefaultUsers

func (store *Store) FollowDefaultUsers(userID globalid.ID) error

func (*Store) GetAnnouncementForNotification

func (store *Store) GetAnnouncementForNotification(n *model.Notification) (*model.Announcement, error)

func (*Store) GetAnnouncements

func (store *Store) GetAnnouncements() ([]*model.Announcement, error)

func (*Store) GetAnonymousAlias

func (store *Store) GetAnonymousAlias(id globalid.ID) (*model.AnonymousAlias, error)

GetAnonymousAlias ---

func (*Store) GetAnonymousAliasByUsername

func (store *Store) GetAnonymousAliasByUsername(username string) (*model.AnonymousAlias, error)

func (*Store) GetAnonymousAliasLastUsed

func (store *Store) GetAnonymousAliasLastUsed(userID, threadRootID globalid.ID) (bool, error)

func (*Store) GetAnonymousAliases

func (store *Store) GetAnonymousAliases() ([]*model.AnonymousAlias, error)

func (*Store) GetAnonymousAliasesByID

func (store *Store) GetAnonymousAliasesByID(ids []globalid.ID) ([]*model.AnonymousAlias, error)

func (*Store) GetCard

func (store *Store) GetCard(id globalid.ID) (*model.Card, error)

GetCard reads the given card from the database.

func (*Store) GetCards

func (store *Store) GetCards() ([]*model.Card, error)

GetCards reads all cards from the database.

func (*Store) GetCardsByIDs

func (store *Store) GetCardsByIDs(ids []globalid.ID) ([]*model.Card, error)

func (*Store) GetCardsByInterval

func (store *Store) GetCardsByInterval(from, to time.Time) ([]*model.Card, error)

GetCardsByInterval returns cards posted in a certain time period.

func (*Store) GetCardsByNodeInRange

func (store *Store) GetCardsByNodeInRange(nodeID globalid.ID, from, to time.Time) ([]*model.Card, error)

GetCardsByNodeInRange returns cards posted by a user in a certain time period.

func (*Store) GetCardsForChannel

func (store *Store) GetCardsForChannel(channelID globalid.ID, count, skip int, forUser globalid.ID) ([]*model.Card, error)

GetCardsForChannel returns cards posted to a channel.

func (*Store) GetCardsForPopularRankSince

func (store *Store) GetCardsForPopularRankSince(t time.Time) ([]*model.PopularRankEntry, error)

func (*Store) GetCardsInFeed

func (store *Store) GetCardsInFeed(userID globalid.ID) ([]globalid.ID, error)

func (*Store) GetCardsWithDeletedByID

func (store *Store) GetCardsWithDeletedByID(ids []globalid.ID) ([]*model.Card, error)

func (*Store) GetChannel

func (store *Store) GetChannel(id globalid.ID) (*model.Channel, error)

GetCard reads the given card from the database.

func (*Store) GetChannelByHandle

func (store *Store) GetChannelByHandle(handle string) (*model.Channel, error)

GetCard reads the given card from the database.

func (*Store) GetChannelEngagements

func (store *Store) GetChannelEngagements() ([]*model.ChannelEngagement, error)

GetCardsForChannel returns cards posted to a channel.

func (*Store) GetChannelInfos

func (store *Store) GetChannelInfos(userID globalid.ID) ([]*model.ChannelUserInfo, error)

GetCard reads the given card from the database.

func (*Store) GetChannels

func (store *Store) GetChannels() ([]*model.Channel, error)

GetCard reads the given card from the database.

func (*Store) GetChannelsByID

func (store *Store) GetChannelsByID(ids []globalid.ID) ([]*model.Channel, error)

func (*Store) GetChannelsForUser

func (store *Store) GetChannelsForUser(userID globalid.ID) ([]*model.Channel, error)

GetCard reads the given card from the database.

func (*Store) GetCoinsReceivedNotificationData

func (store *Store) GetCoinsReceivedNotificationData(notif *model.Notification) (*model.CoinReward, error)

func (*Store) GetCommentCount

func (store *Store) GetCommentCount(startDate, endDate time.Time) ([]*model.Count, error)

func (*Store) GetCommentExportData

func (store *Store) GetCommentExportData(n *model.Notification) (*CommentNotificationExportData, error)

func (*Store) GetCurrentBalance

func (store *Store) GetCurrentBalance(userID globalid.ID) (*model.CoinBalances, error)

func (*Store) GetDaysActive

func (store *Store) GetDaysActive(startDate, endDate time.Time) ([]*model.Count, error)

func (*Store) GetDefaultChannelIDs

func (store *Store) GetDefaultChannelIDs() ([]globalid.ID, error)

GetCard reads the given card from the database.

func (*Store) GetEngagement

func (store *Store) GetEngagement(cardID globalid.ID) (*model.Engagement, error)

GetEngagement derives engagement for a given card from the cards and reactions table.

The query is at its core a UNION between reactions and cards table. Reactions are filtered by boosts minus reactions to a user's own card. If there is a more recent bury from the user, the boost is not included at all.

Only cards that are replies to the given card are included for the engagement.

The engagement type is determined by the originating row. It's a 'comment' if it's from the cards table and a 'boost' if it is from the reactions table. In case there is a comment and a boost, precedence to the comment is given (see CASE WHEN statement).

In order to fetch associated user or anonymous alias information JOINS are applied. An INNER JOIN for user because the user data is always available and a LEFT JOIN on anonymous alias because the anonymous alias data is only sometimes available.

In order to protect the identity of an anonymous engagement, a COALESCE statement is used to give precedence to the anonymous information.

func (*Store) GetEngagements

func (store *Store) GetEngagements(cardIDs []globalid.ID) (map[globalid.ID]*model.Engagement, error)

func (*Store) GetFeatureSwitches

func (store *Store) GetFeatureSwitches() ([]*model.FeatureSwitch, error)

GetSavedLink returns the saved link for the provided ID

func (*Store) GetFeedCardsFromCurrentTop

func (store *Store) GetFeedCardsFromCurrentTop(userID globalid.ID, perPage, page int) ([]*model.Card, error)

GetFeedCardsFromCurrentTop fetches all the cards which are in a users current feed.

func (*Store) GetFeedCardsFromCurrentTopWithQuery

func (store *Store) GetFeedCardsFromCurrentTopWithQuery(userID globalid.ID, perPage, page int, searchString string) ([]*model.Card, error)

GetFeedCardsFromCurrentTop fetches all the cards which are in a users current feed.

func (*Store) GetFlatReplies

func (store *Store) GetFlatReplies(id, forUser globalid.ID, latestFirst bool, limitTo int) ([]*model.Card, error)

GetThread returns all cards with who are replying to the same card. This is used to display a thread on the application and excludes the thread root.

func (*Store) GetFollowExportData

func (store *Store) GetFollowExportData(n *model.Notification) (*FollowNotificationExportData, error)

func (*Store) GetFollowedCount

func (store *Store) GetFollowedCount(startDate, endDate time.Time) ([]*model.Count, error)

func (*Store) GetFollowedUsersCount

func (store *Store) GetFollowedUsersCount(startDate, endDate time.Time) ([]*model.Count, error)

func (*Store) GetFollowing

func (store *Store) GetFollowing(userID globalid.ID) ([]*model.User, error)

func (*Store) GetIntroCardIDs

func (store *Store) GetIntroCardIDs() ([]globalid.ID, error)

GetCards reads all cards from the database.

func (*Store) GetIntroCards

func (store *Store) GetIntroCards() ([]*model.Card, error)

GetCards reads all cards from the database.

func (*Store) GetInvite

func (store *Store) GetInvite(id globalid.ID) (*model.Invite, error)

GetInviteByToken returns the invite for the provided token

func (*Store) GetInviteByToken

func (store *Store) GetInviteByToken(token string) (*model.Invite, error)

GetInviteByToken returns the invite for the provided token

func (*Store) GetInviteForChannelAndNode

func (store *Store) GetInviteForChannelAndNode(channelID, nodeID globalid.ID) (*model.Invite, error)

GetInvites returns all invites from the store

func (*Store) GetInvitedCount

func (store *Store) GetInvitedCount(startDate, endDate time.Time) ([]*model.Count, error)

func (*Store) GetInvites

func (store *Store) GetInvites() ([]*model.Invite, error)

GetInvites returns all invites from the store

func (*Store) GetInvitesByID

func (store *Store) GetInvitesByID(ids []globalid.ID) ([]*model.Invite, error)

func (*Store) GetInvitesForUser

func (store *Store) GetInvitesForUser(id globalid.ID) ([]*model.Invite, error)

GetInvites returns all invites from the store

func (*Store) GetIsSubscribed

func (store *Store) GetIsSubscribed(userID, channelID globalid.ID) (bool, error)

GetCard reads the given card from the database.

func (*Store) GetLastActiveAt

func (store *Store) GetLastActiveAt(userID globalid.ID) (time.Time, error)

func (*Store) GetLeaderboardNotificationExportData

func (store *Store) GetLeaderboardNotificationExportData(notifID globalid.ID) (*LeaderboardNotificationExportData, error)

func (*Store) GetLeaderboardRankings

func (store *Store) GetLeaderboardRankings(count, skip int) ([]*model.LeaderboardRank, error)

func (*Store) GetLeaderboardRanksFromTransactions

func (store *Store) GetLeaderboardRanksFromTransactions(fromTime, toTime time.Time) ([]*model.LeaderboardRank, error)

func (*Store) GetLikeNotificationExportData

func (store *Store) GetLikeNotificationExportData(n *model.Notification) (*LikeNotificationExportData, error)

func (*Store) GetMentionExportData

func (store *Store) GetMentionExportData(n *model.Notification) (*MentionNotificationExportData, error)

func (*Store) GetNotification

func (store *Store) GetNotification(notifID globalid.ID) (*model.Notification, error)

GetNotifications reads all notifications for a given user from the database.

func (*Store) GetNotifications

func (store *Store) GetNotifications(userID globalid.ID, page, skip int) ([]*model.Notification, error)

GetNotifications reads all notifications for a given user from the database.

func (*Store) GetOAuthAccountBySubject

func (s *Store) GetOAuthAccountBySubject(subject string) (*model.OAuthAccount, error)

GetOAuthAccountBySubject returns the OAuth account from the database with the given subject. This is limited to Facebook OAuth accounts for now.

func (*Store) GetOnSwitches

func (store *Store) GetOnSwitches() ([]*model.FeatureSwitch, error)

GetSavedLink returns the saved link for the provided ID

func (*Store) GetPopularPostNotificationExportData

func (store *Store) GetPopularPostNotificationExportData(n *model.Notification) (*PopularPostNotificationExportData, error)

func (*Store) GetPopularRankCardsForUser

func (store *Store) GetPopularRankCardsForUser(userID globalid.ID, perPage, page int) ([]*model.Card, error)

func (*Store) GetPopularRankForCard

func (store *Store) GetPopularRankForCard(cardID globalid.ID) (*model.PopularRankEntry, error)

func (*Store) GetPostCount

func (store *Store) GetPostCount(startDate, endDate time.Time) ([]*model.Count, error)

func (*Store) GetPostedCardsForNode

func (store *Store) GetPostedCardsForNode(nodeID globalid.ID, count, skip int) ([]*model.Card, error)

GetPostedCardsForNode returns the number of cards posted by a user.

func (*Store) GetPostedCardsForNodeIncludingAnon

func (store *Store) GetPostedCardsForNodeIncludingAnon(nodeID globalid.ID, count, skip int) ([]*model.Card, error)

GetPostedCardsForNodeIncludingAnon returns the number of cards posted by a user.

func (*Store) GetRankableCardsForExampleFeed

func (store *Store) GetRankableCardsForExampleFeed(channels []globalid.ID, postedAfter time.Time) ([]*model.PopularRankEntry, error)

func (*Store) GetRankableCardsForUser

func (store *Store) GetRankableCardsForUser(userID globalid.ID) ([]*model.PopularRankEntry, error)

func (*Store) GetRankedImmediateReplies

func (store *Store) GetRankedImmediateReplies(cardID, forUser globalid.ID) ([]*model.Card, error)

GetThread returns all cards with who are replying to the same card. This is used to display a thread on the application and excludes the thread root.

func (*Store) GetReactedCount

func (store *Store) GetReactedCount(startDate, endDate time.Time) ([]*model.Count, error)

func (*Store) GetReceivedReactionsCount

func (store *Store) GetReceivedReactionsCount(startDate, endDate time.Time) ([]*model.Count, error)

func (*Store) GetResetToken

func (store *Store) GetResetToken(userID globalid.ID) (*model.ResetToken, error)

GetResetToken reads a reset token from the database.

func (*Store) GetSafeUsersByPage

func (store *Store) GetSafeUsersByPage(forUser globalid.ID, pageSize, pageNumber int, searchString string) ([]*model.User, error)

func (*Store) GetSession

func (store *Store) GetSession(id globalid.ID) (*model.Session, error)

func (*Store) GetSessions

func (store *Store) GetSessions() ([]*model.Session, error)

func (*Store) GetSettings

func (store *Store) GetSettings() (*model.Settings, error)

func (*Store) GetSubscribedChannels

func (store *Store) GetSubscribedChannels(userID globalid.ID) ([]*model.Channel, error)

GetCard reads the given card from the database.

func (*Store) GetSubscriberCount

func (store *Store) GetSubscriberCount(channelID globalid.ID) (int, error)

GetCard reads the given card from the database.

func (*Store) GetSwitchByName

func (store *Store) GetSwitchByName(name string) (*model.FeatureSwitch, error)

GetSavedLink returns the saved link for the provided ID

func (*Store) GetThread

func (store *Store) GetThread(id, forUser globalid.ID) ([]*model.Card, error)

GetThread returns all cards with who are replying to the same card. This is used to display a thread on the application and excludes the thread root.

func (*Store) GetThreadCount

func (store *Store) GetThreadCount(id globalid.ID) (int, error)

func (*Store) GetThreadCounts

func (store *Store) GetThreadCounts(ids []globalid.ID) (map[globalid.ID]int, error)

func (*Store) GetTotalDislikeCount

func (store *Store) GetTotalDislikeCount(startDate, endDate time.Time) ([]*model.Count, error)

func (*Store) GetTotalLikeCount

func (store *Store) GetTotalLikeCount(startDate, endDate time.Time) ([]*model.Count, error)

func (*Store) GetTotalReplyCount

func (store *Store) GetTotalReplyCount(startDate, endDate time.Time) ([]*model.Count, error)

func (*Store) GetUniqueUserCommentCount

func (store *Store) GetUniqueUserCommentCount(startDate, endDate time.Time) ([]*model.Count, error)

func (*Store) GetUnusedAlias

func (store *Store) GetUnusedAlias(cardID globalid.ID) (*model.AnonymousAlias, error)

func (*Store) GetUser

func (store *Store) GetUser(id globalid.ID) (*model.User, error)

func (*Store) GetUserByEmail

func (store *Store) GetUserByEmail(email string) (*model.User, error)

func (*Store) GetUserByUsername

func (store *Store) GetUserByUsername(username string) (*model.User, error)

GetUserByUsername reads a username identified by its username from the database.

func (*Store) GetUserCount

func (store *Store) GetUserCount() (int, error)

func (*Store) GetUserIDs

func (store *Store) GetUserIDs() ([]globalid.ID, error)

func (*Store) GetUserReaction

func (store *Store) GetUserReaction(userID, cardID globalid.ID) (*model.UserReaction, error)

func (*Store) GetUserReactions

func (store *Store) GetUserReactions(userID globalid.ID, cardIDs []globalid.ID) (map[globalid.ID]*model.UserReaction, error)

func (*Store) GetUsers

func (store *Store) GetUsers() ([]*model.User, error)

func (*Store) GetUsersByID

func (store *Store) GetUsersByID(ids []globalid.ID) ([]*model.User, error)

func (*Store) GetUsersByUsernames

func (store *Store) GetUsersByUsernames(usernames []string) ([]*model.User, error)

func (*Store) GetUsersNeedingFirstPostNotification

func (store *Store) GetUsersNeedingFirstPostNotification() ([]*model.User, error)

func (*Store) GetUsersWithoutDelayedInvites

func (store *Store) GetUsersWithoutDelayedInvites() ([]*model.User, error)

func (*Store) GetWaitlist

func (store *Store) GetWaitlist() ([]*model.WaitlistEntry, error)

func (*Store) GroupInvitesByToken

func (store *Store) GroupInvitesByToken(tokens []string, groupID globalid.ID) error

Groups invites together

func (*Store) IsFollowing

func (store *Store) IsFollowing(followerID, followeeID globalid.ID) (bool, error)

func (*Store) IsFollowings

func (store *Store) IsFollowings(followerID globalid.ID, followeeID []globalid.ID) (map[globalid.ID]bool, error)

func (*Store) IsSubscribedToChannels

func (store *Store) IsSubscribedToChannels(userID globalid.ID, channelIDs []globalid.ID) (map[globalid.ID]bool, error)

func (*Store) JoinChannel

func (store *Store) JoinChannel(userID, channelID globalid.ID) error

func (*Store) LatestForType

func (store *Store) LatestForType(userID, targetID globalid.ID, typ string, unopenedOnly bool) (*model.Notification, error)

GetNotifications reads all notifications for a given user from the database.

func (*Store) LeaveAllChannels

func (store *Store) LeaveAllChannels(userID globalid.ID) error

func (*Store) LeaveChannel

func (store *Store) LeaveChannel(userID, channelID globalid.ID) error

func (*Store) MustBegin

func (store *Store) MustBegin() *Tx

func (*Store) MuteChannel

func (store *Store) MuteChannel(userID, channelID globalid.ID) error

func (*Store) MuteThread

func (store *Store) MuteThread(userID, threadRootID globalid.ID) error

func (*Store) MuteUser

func (store *Store) MuteUser(userID, mutedUserID globalid.ID) error

func (*Store) NewContentAvailableForUser

func (store *Store) NewContentAvailableForUser(userID, cardID globalid.ID) (bool, error)

func (*Store) NewContentAvailableForUserByCards

func (store *Store) NewContentAvailableForUserByCards(userID globalid.ID, cardIDs []globalid.ID) (map[globalid.ID]bool, error)

func (*Store) PayCoinAmount

func (store *Store) PayCoinAmount(userID globalid.ID, amount int64) error

func (*Store) ReassignInviterForGroup

func (store *Store) ReassignInviterForGroup(rootInviteID, newUserID globalid.ID) error

func (*Store) ReassignInvitesByToken

func (store *Store) ReassignInvitesByToken(tokens []string, userID globalid.ID) error

func (*Store) ResetTemporaryCoins

func (store *Store) ResetTemporaryCoins(newBalance int64) error

func (*Store) ResetUserFeedTop

func (store *Store) ResetUserFeedTop(userID globalid.ID) error

func (*Store) SaveActivity

func (store *Store) SaveActivity(m *model.Activity) error

func (*Store) SaveAnnouncement

func (store *Store) SaveAnnouncement(m *model.Announcement) error

SaveAnnouncement saves an Announcement to the store

func (*Store) SaveAnonymousAlias

func (store *Store) SaveAnonymousAlias(m *model.AnonymousAlias) error

func (*Store) SaveCard

func (store *Store) SaveCard(m *model.Card) error

SaveCard saves a card

func (*Store) SaveChannel

func (store *Store) SaveChannel(m *model.Channel) error

SaveCard saves a card

func (*Store) SaveCoinTransaction

func (store *Store) SaveCoinTransaction(m *model.CoinTransaction) error

SaveCard saves a card

func (*Store) SaveFeatureSwitch

func (store *Store) SaveFeatureSwitch(m *model.FeatureSwitch) error

func (*Store) SaveFollower

func (store *Store) SaveFollower(followerID, followeeID globalid.ID) error

func (*Store) SaveInvite

func (store *Store) SaveInvite(m *model.Invite) error

SaveInvite saves an invite to the store

func (*Store) SaveLeaderboardNotificationData

func (store *Store) SaveLeaderboardNotificationData(notifID globalid.ID, rank int) error

func (*Store) SaveLeaderboardRank

func (store *Store) SaveLeaderboardRank(m *model.LeaderboardRank) error

func (*Store) SaveMention

func (store *Store) SaveMention(m *model.Mention) error

SaveNotification saves an notification to the store

func (*Store) SaveNotification

func (store *Store) SaveNotification(m *model.Notification) error

SaveNotification saves an notification to the store

func (*Store) SaveNotificationComment

func (store *Store) SaveNotificationComment(m *model.NotificationComment) error

SaveInvite saves an invite to the store

func (*Store) SaveNotificationFollow

func (store *Store) SaveNotificationFollow(notifID, followerID, followeeID globalid.ID) error

SaveInvite saves an invite to the store

func (*Store) SaveNotificationMention

func (store *Store) SaveNotificationMention(m *model.NotificationMention) error

SaveNotification saves an notification to the store

func (*Store) SaveOAuthAccount

func (s *Store) SaveOAuthAccount(m *model.OAuthAccount) error

func (*Store) SavePopularRank

func (store *Store) SavePopularRank(m *model.PopularRankEntry) error

func (*Store) SaveReactionForNotification

func (store *Store) SaveReactionForNotification(notifID, userID, cardID globalid.ID) error

func (*Store) SaveResetToken

func (store *Store) SaveResetToken(m *model.ResetToken) error

SaveResetToken writes a reset token to the database.

func (*Store) SaveScoreModification

func (store *Store) SaveScoreModification(m *model.ScoreModification) error

func (*Store) SaveSession

func (store *Store) SaveSession(m *model.Session) error

func (*Store) SaveSettings

func (store *Store) SaveSettings(m *model.Settings) error

func (*Store) SaveUser

func (store *Store) SaveUser(m *model.User) error

SaveUser will update an existing user or create a new user record in the datastore.

func (*Store) SaveUserReaction

func (store *Store) SaveUserReaction(m *model.UserReaction) error

func (*Store) SaveUserTip

func (store *Store) SaveUserTip(m *model.UserTip) error

SaveInvite saves an invite to the store

func (*Store) SaveWaitlistEntry

func (store *Store) SaveWaitlistEntry(m *model.WaitlistEntry) error

func (*Store) SetCardVisited

func (store *Store) SetCardVisited(userID, cardID globalid.ID) error

func (*Store) SetFeedLastUpdatedForUser

func (store *Store) SetFeedLastUpdatedForUser(userID globalid.ID, t time.Time) error

func (*Store) SetIntroCardStatus

func (store *Store) SetIntroCardStatus(cardID globalid.ID, status bool) error

func (*Store) ShadowbanAllCardsForUser

func (store *Store) ShadowbanAllCardsForUser(userID globalid.ID) error

func (*Store) ShadowbanCard

func (store *Store) ShadowbanCard(cardID globalid.ID) error

func (*Store) SubscribeToCard

func (store *Store) SubscribeToCard(userID, cardID globalid.ID, typ string) error

func (*Store) SubscribedToCards

func (store *Store) SubscribedToCards(userID globalid.ID, cardIDs []globalid.ID) (map[globalid.ID]bool, error)

func (*Store) SubscribedToTypes

func (store *Store) SubscribedToTypes(userID, cardID globalid.ID) ([]string, error)

func (*Store) SubscribersForCard

func (store *Store) SubscribersForCard(cardID globalid.ID, typ string) ([]globalid.ID, error)

func (*Store) SubtractCoinsFromBalance

func (store *Store) SubtractCoinsFromBalance(userID globalid.ID, amount int) error

func (*Store) ToggleUserForFeature

func (store *Store) ToggleUserForFeature(featureID, userID globalid.ID) error

GetSavedLink returns the saved link for the provided ID

func (*Store) UnmuteChannel

func (store *Store) UnmuteChannel(userID, channelID globalid.ID) error

func (*Store) UnmuteThread

func (store *Store) UnmuteThread(userID, threadRootID globalid.ID) error

func (*Store) UnmuteUser

func (store *Store) UnmuteUser(userID, mutedUserID globalid.ID) error

func (*Store) UnseenNotificationsCount

func (store *Store) UnseenNotificationsCount(userID globalid.ID) (int, error)

GetNotifications reads all notifications for a given user from the database.

func (*Store) UnshadowbanCard

func (store *Store) UnshadowbanCard(cardID globalid.ID) error

func (*Store) UnsubscribeFromCard

func (store *Store) UnsubscribeFromCard(userID, cardID globalid.ID, typ string) error

func (*Store) UpdateAllNotificationsSeen

func (store *Store) UpdateAllNotificationsSeen(userID globalid.ID) error

UpdateNotifcationsSeen marks notifications as seen by setting the last seen at column to now.

func (*Store) UpdateCardRanksForUser

func (store *Store) UpdateCardRanksForUser(userID globalid.ID, cardIDs []globalid.ID) error

func (*Store) UpdateNotificationsOpened

func (store *Store) UpdateNotificationsOpened(ids []globalid.ID) error

UpdateNotifcationsOpened marks notifications as opened by setting the last opened at column to now.

func (*Store) UpdateNotificationsSeen

func (store *Store) UpdateNotificationsSeen(ids []globalid.ID) error

UpdateNotifcationsSeen marks notifications as seen by setting the last seen at column to now.

func (*Store) UpdatePopularRankForCard

func (store *Store) UpdatePopularRankForCard(cardID globalid.ID, viewCountChange, upCountChange, downCountChange, commentCountChange int64, scoreModChange float64) error

func (*Store) UpdatePopularRanksForUser

func (store *Store) UpdatePopularRanksForUser(userID globalid.ID) error

func (*Store) UpdatePopularRanksWithList

func (store *Store) UpdatePopularRanksWithList(userID globalid.ID, ids []globalid.ID) error

func (*Store) UpdateUniqueCommentersForCard

func (store *Store) UpdateUniqueCommentersForCard(cardID globalid.ID) error

func (*Store) UpdateUserGotDelayedInvites

func (store *Store) UpdateUserGotDelayedInvites(id globalid.ID) error

func (*Store) UpdateViewsForCards

func (store *Store) UpdateViewsForCards(cardIDs []globalid.ID) error

func (*Store) UpdateWaitlistEntry

func (store *Store) UpdateWaitlistEntry(email, comment string) error

func (*Store) UsersWithPopularPostsSinceTime

func (store *Store) UsersWithPopularPostsSinceTime(t time.Time) ([]*model.User, error)

type Tx

type Tx struct {
	*sqlx.Tx
}

func (*Tx) SaveActivity

func (tx *Tx) SaveActivity(m *model.Activity) error

func (*Tx) SaveAnnouncement

func (tx *Tx) SaveAnnouncement(m *model.Announcement) error

SaveAnnouncement saves an Announcement to the store

func (*Tx) SaveCard

func (tx *Tx) SaveCard(m *model.Card) error

SaveCard saves a card

func (*Tx) SaveChannel

func (tx *Tx) SaveChannel(m *model.Channel) error

SaveCard saves a card

func (*Tx) SaveCoinTransaction

func (tx *Tx) SaveCoinTransaction(m *model.CoinTransaction) error

SaveCard saves a card

func (*Tx) SaveFeatureSwitch

func (tx *Tx) SaveFeatureSwitch(m *model.FeatureSwitch) error

func (*Tx) SaveFollower

func (tx *Tx) SaveFollower(followerID, followeeID globalid.ID) error

func (*Tx) SaveInvite

func (tx *Tx) SaveInvite(m *model.Invite) error

SaveInvite saves an invite to the store

func (*Tx) SaveMention

func (tx *Tx) SaveMention(m *model.Mention) error

SaveNotification saves an notification to the store

func (*Tx) SaveNotification

func (tx *Tx) SaveNotification(m *model.Notification) error

SaveNotification saves an notification to the store

func (*Tx) SaveNotificationComment

func (tx *Tx) SaveNotificationComment(m *model.NotificationComment) error

SaveInvite saves an invite to the store

func (*Tx) SaveNotificationFollow

func (tx *Tx) SaveNotificationFollow(notifID, followerID, followeeID globalid.ID) error

SaveInvite saves an invite to the store

func (*Tx) SaveNotificationMention

func (tx *Tx) SaveNotificationMention(m *model.NotificationMention) error

SaveNotification saves an notification to the store

func (*Tx) SaveOAuthAccount

func (tx *Tx) SaveOAuthAccount(m *model.OAuthAccount) error

func (*Tx) SaveResetToken

func (tx *Tx) SaveResetToken(m *model.ResetToken) error

SaveResetToken writes a reset token to the database.

func (*Tx) SaveScoreModification

func (tx *Tx) SaveScoreModification(m *model.ScoreModification) error

func (*Tx) SaveSession

func (tx *Tx) SaveSession(m *model.Session) error

func (*Tx) SaveSettings

func (tx *Tx) SaveSettings(m *model.Settings) error

func (*Tx) SaveUser

func (tx *Tx) SaveUser(m *model.User) error

SaveUser will update an existing user or create a new user record in the datastore.

func (*Tx) SaveUserTip

func (tx *Tx) SaveUserTip(m *model.UserTip) error

SaveInvite saves an invite to the store

func (*Tx) SaveWaitlistEntry

func (tx *Tx) SaveWaitlistEntry(m *model.WaitlistEntry) error

Jump to

Keyboard shortcuts

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