Documentation ¶
Index ¶
Constants ¶
const UniqueConstraintViolationCode = "23505"
UniqueConstraintViolationCode is error returned by PostgreSQL instance when violation of uniqueness in table happens.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Connection ¶
Connection is wrapper for sql.DB struct. Name is easier to reason about. It provides a lot clarity in the code.
func NewPostgresDatabase ¶
func NewPostgresDatabase(config config.DatabaseConfigProvider) *Connection
NewPostgresDatabase returns new connection to PostgreSQL database. All configurations can be specified in config file.
type FollowsDAO ¶
type FollowsDAO interface { FollowUser(followeeID, followerID int64) (bool, error) UnfollowUser(followeeID, followerID int64) (bool, error) GetFollowersIDs(userID int64) ([]int64, error) GetFolloweesIDs(userID int64) ([]int64, error) GetFollowerCount(userID int64) (int64, error) GetFolloweeCount(userID int64) (int64, error) IsFollowing(followerID, followeeID int64) (bool, error) }
FollowsDAO (Follows Data Access Object) is interface that provides operations on Follows database table.
func NewFollowsDAO ¶
func NewFollowsDAO(conn *Connection) FollowsDAO
NewFollowsDAO creates new struct which implements FollowsDAO functions.
type LikesDAO ¶
type LikesDAO interface { LikeTweet(tweetID, userID int64) (bool, error) UnlikeTweet(tweetID, userID int64) (bool, error) GetLikeCount(tweetID int64) (int64, error) IsLiked(tweetID, userID int64) (bool, error) }
LikesDAO (Likes Data Access Object) is interface which provides operations on Likes database table.
func NewLikesDAO ¶
func NewLikesDAO(conn *Connection) LikesDAO
NewLikesDAO creates new struct which implements LikesDAO functions.
type TweetsDAO ¶
type TweetsDAO interface { GetTweetsIDsByAuthorID(userID int64) ([]int64, error) GetTweetsByIDs(tweetsIDs []int64) ([]*model.Tweet, error) GetTweetByID(tweetID int64) (*model.Tweet, error) InsertTweet(newTweet *model.NewTweet) (*model.Tweet, error) DeleteTweet(tweetID int64) error }
TweetsDAO (Tweets Data Access Object) is interface which provides operations on Tweet database table.
func NewTweetDAO ¶
func NewTweetDAO(conn *Connection) TweetsDAO
NewTweetDAO creates new struct which implements TweetDAO functions.
type UsersDAO ¶
type UsersDAO interface { GetPublicUsers() ([]*model.PublicUser, error) GetPublicUserByID(userID int64) (*model.PublicUser, error) GetUserByEmail(userEmail string) (*model.User, error) InsertUser(user *model.NewUserForm) (*model.PublicUser, error) UpdateUserLastLoginTime(userID int64, lastLoginTime *time.Time) error }
UsersDAO (Users Data Access Object) is interface which provides operations on User database table.
func NewUserDAO ¶
func NewUserDAO(conn *Connection) UsersDAO
NewUserDAO creates new struct which implements UserDAO functions.