sqldb

package
v0.0.0-...-5c487ac Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SQLBool

func SQLBool(value bool) int

SQLBool converts Go lang bool to the corresponding SQL data type representing boolean.

Types

type APIKeySQL

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

APIKeySQL accesses APIKey from the database through SQL.

func NewAPIKeySQL

func NewAPIKeySQL(db *sql.DB) APIKeySQL

NewAPIKeySQL creates database access object for APIKey.

func (APIKeySQL) CreateAPIKey

func (a APIKeySQL) CreateAPIKey(input entity.APIKeyInput) (entity.APIKey, error)

CreateAPIKey appends a new APIKey entry to APIKey table using SQL.

func (APIKeySQL) GetAPIKey

func (a APIKeySQL) GetAPIKey(appID string, key string) (entity.APIKey, error)

GetAPIKey fetches APIKey from APIKey table using SQL.

type AppSQL

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

AppSQL access third party app info through in SQL database.

func NewAppSQL

func NewAppSQL(db *sql.DB) AppSQL

NewAppSQL creates AppSQL.

func (AppSQL) GetAppByID

func (a AppSQL) GetAppByID(id string) (entity.App, error)

GetAppByID fetches an app with given ID from SQL DB.

type ChangeLogSQL

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

ChangeLogSQL accesses ChangeLog information in change_log table through SQL.

func NewChangeLogSQL

func NewChangeLogSQL(db *sql.DB) ChangeLogSQL

NewChangeLogSQL creates ChangeLogSQL

func (ChangeLogSQL) CreateChange

func (c ChangeLogSQL) CreateChange(newChange entity.Change) (entity.Change, error)

CreateChange adds a new Change into change_log table.

func (ChangeLogSQL) DeleteChange

func (c ChangeLogSQL) DeleteChange(id string) error

DeleteChange removes a change with the given id

func (ChangeLogSQL) GetChangeLog

func (c ChangeLogSQL) GetChangeLog() ([]entity.Change, error)

GetChangeLog retrieves full changelog from change_log table.

func (ChangeLogSQL) UpdateChange

func (c ChangeLogSQL) UpdateChange(newChange entity.Change) (entity.Change, error)

UpdateChange updates an existing change in change_log table.

type FacebookSSOSql

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

FacebookSSOSql accesses mapping between Facebook and Short accounts in SQL database.

func NewFacebookSSOSql

func NewFacebookSSOSql(db *sql.DB, logger logger.Logger) FacebookSSOSql

NewFacebookSSOSql creates FacebookSSOSql.

func (FacebookSSOSql) CreateMapping

func (g FacebookSSOSql) CreateMapping(ssoUserID string, userID string) error

CreateMapping creates links user's Facebook and Short accounts in the database.

func (FacebookSSOSql) GetShortUserID

func (g FacebookSSOSql) GetShortUserID(ssoUserID string) (string, error)

GetShortUserID retrieves the internal user ID that is linked to the user's Facebook account.

func (FacebookSSOSql) IsSSOUserExist

func (g FacebookSSOSql) IsSSOUserExist(ssoUserID string) (bool, error)

IsSSOUserExist checks whether mapping for a given Facebook account exists in the database.

type FeatureToggleSQL

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

FeatureToggleSQL accesses feature toggle information in feature_toggle table through SQL.

func NewFeatureToggleSQL

func NewFeatureToggleSQL(db *sql.DB) FeatureToggleSQL

NewFeatureToggleSQL create FeatureToggleSQL repository.

func (FeatureToggleSQL) FindToggleByID

func (f FeatureToggleSQL) FindToggleByID(id string) (entity.Toggle, error)

FindToggleByID fetches feature toggle from the database given toggle id.

type GithubSSOSql

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

GithubSSOSql accesses mapping between Github and Short accounts in the SQL database.

func NewGithubSSOSql

func NewGithubSSOSql(db *sql.DB, logger logger.Logger) GithubSSOSql

NewGithubSSOSql creates GithubSSOSql.

func (GithubSSOSql) CreateMapping

func (g GithubSSOSql) CreateMapping(ssoUserID string, userID string) error

CreateMapping links user's Github and Short accounts in the database.

func (GithubSSOSql) GetShortUserID

func (g GithubSSOSql) GetShortUserID(ssoUserID string) (string, error)

GetShortUserID retrieves the internal user ID that is linked to the user's Github account.

func (GithubSSOSql) IsSSOUserExist

func (g GithubSSOSql) IsSSOUserExist(ssoUserID string) (bool, error)

IsSSOUserExist checks whether mapping for a given Github account exists in the database.

type GoogleSSOSql

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

GoogleSSOSql accesses mapping between Google and Short accounts in the SQL database.

func NewGoogleSSOSql

func NewGoogleSSOSql(db *sql.DB, logger logger.Logger) GoogleSSOSql

NewGoogleSSOSql creates GoogleSSOSql.

func (GoogleSSOSql) CreateMapping

func (g GoogleSSOSql) CreateMapping(ssoUserID string, userID string) error

CreateMapping creates links user's Google and Short accounts in the database.

func (GoogleSSOSql) GetShortUserID

func (g GoogleSSOSql) GetShortUserID(ssoUserID string) (string, error)

GetShortUserID retrieves the internal user ID that is linked to the user's Google account.

func (GoogleSSOSql) IsSSOUserExist

func (g GoogleSSOSql) IsSSOUserExist(ssoUserID string) (bool, error)

IsSSOUserExist checks whether mapping for a given Google account exists in the database.

type ShortLinkSQL

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

ShortLinkSQL accesses ShortLink information in short_link table through SQL.

func NewShortLinkSQL

func NewShortLinkSQL(db *sql.DB) ShortLinkSQL

NewShortLinkSQL creates ShortLinkSQL

func (s ShortLinkSQL) CreateShortLink(shortLinkInput entity.ShortLinkInput) error

CreateShortLink inserts a new ShortLink into short_link table.

func (s ShortLinkSQL) DeleteShortLink(alias string) error

DeleteShortLink deletes an existing user short link.

func (ShortLinkSQL) GetShortLinkByAlias

func (s ShortLinkSQL) GetShortLinkByAlias(alias string) (entity.ShortLink, error)

GetShortLinkByAlias finds an ShortLink in short_link table given alias.

func (ShortLinkSQL) GetShortLinksByAliases

func (s ShortLinkSQL) GetShortLinksByAliases(aliases []string) ([]entity.ShortLink, error)

GetShortLinksByAliases finds ShortLinks for a list of aliases

func (ShortLinkSQL) IsAliasExist

func (s ShortLinkSQL) IsAliasExist(alias string) (bool, error)

IsAliasExist checks whether a given alias exist in short_link table.

func (ShortLinkSQL) UpdateOpenGraphTags

func (s ShortLinkSQL) UpdateOpenGraphTags(alias string, openGraphTags metatag.OpenGraph) (entity.ShortLink, error)

UpdateOpenGraphTags updates OpenGraph meta tags for a given short link.

func (s ShortLinkSQL) UpdateShortLink(oldAlias string, shortLinkInput entity.ShortLinkInput) (entity.ShortLink, error)

UpdateShortLink updates a ShortLink that exists within the short_link table.

func (ShortLinkSQL) UpdateTwitterTags

func (s ShortLinkSQL) UpdateTwitterTags(alias string, twitterTags metatag.Twitter) (entity.ShortLink, error)

UpdateTwitterTags updates Twitter meta tags for a given short link.

type UserChangeLogSQL

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

UserChangeLogSQL accesses UserChangeLog information in user_changelog table through SQL.

func NewUserChangeLogSQL

func NewUserChangeLogSQL(db *sql.DB) UserChangeLogSQL

NewUserChangeLogSQL creates UserChangeLogSQL

func (UserChangeLogSQL) CreateRelation

func (u UserChangeLogSQL) CreateRelation(user entity.User, currentTime time.Time) error

CreateRelation inserts a new entry into user_changelog table.

func (UserChangeLogSQL) GetLastViewedAt

func (u UserChangeLogSQL) GetLastViewedAt(user entity.User) (time.Time, error)

GetLastViewedAt retrieves LastViewedAt for a given user.

func (UserChangeLogSQL) UpdateLastViewedAt

func (u UserChangeLogSQL) UpdateLastViewedAt(user entity.User, currentTime time.Time) (time.Time, error)

UpdateLastViewedAt updates LastViewedAt for the given user.

type UserRoleSQL

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

UserRoleSQL accesses a user's role information in user_role table through SQL.

func NewUserRoleSQL

func NewUserRoleSQL(db *sql.DB) UserRoleSQL

NewUserRoleSQL creates UserRoleSQL

func (UserRoleSQL) AddRole

func (u UserRoleSQL) AddRole(user entity.User, r role.Role) error

AddRole assigns the given role to the user

func (UserRoleSQL) DeleteRole

func (u UserRoleSQL) DeleteRole(user entity.User, r role.Role) error

DeleteRole removes the given role from the user

func (UserRoleSQL) GetRoles

func (u UserRoleSQL) GetRoles(user entity.User) ([]role.Role, error)

GetRoles fetches all the roles for a given user

type UserSQL

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

UserSQL accesses User information in user table through SQL.

func NewUserSQL

func NewUserSQL(db *sql.DB) UserSQL

NewUserSQL creates UserSQL

func (UserSQL) CreateUser

func (u UserSQL) CreateUser(user entity.User) error

CreateUser inserts a new User into user table.

func (UserSQL) GetUserByEmail

func (u UserSQL) GetUserByEmail(email string) (entity.User, error)

GetUserByEmail finds an User in user table given email.

func (UserSQL) GetUserByID

func (u UserSQL) GetUserByID(id string) (entity.User, error)

GetUserByID finds an User in user table given user ID.

func (UserSQL) IsEmailExist

func (u UserSQL) IsEmailExist(email string) (bool, error)

IsEmailExist checks whether a given email exists in user table.

func (UserSQL) IsIDExist

func (u UserSQL) IsIDExist(id string) (bool, error)

IsIDExist checks whether a given user ID exists in user table.

type UserShortLinkSQL

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

UserShortLinkSQL accesses UserShortLink information in user_short_link table.

func NewUserShortLinkSQL

func NewUserShortLinkSQL(db *sql.DB) UserShortLinkSQL

NewUserShortLinkSQL creates UserShortLinkSQL

func (UserShortLinkSQL) CreateRelation

func (u UserShortLinkSQL) CreateRelation(user entity.User, shortLinkInput entity.ShortLinkInput) error

CreateRelation establishes bi-directional relationship between a user and a short link in user_short_link table.

func (UserShortLinkSQL) FindAliasesByUser

func (u UserShortLinkSQL) FindAliasesByUser(user entity.User) ([]string, error)

FindAliasesByUser fetches the aliases of all the ShortLinks created by the given user. TODO(issue#260): allow API client to filter urls based on visibility.

func (UserShortLinkSQL) HasMapping

func (u UserShortLinkSQL) HasMapping(user entity.User, alias string) (bool, error)

HasMapping checks whether a given short link is tied to a user.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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