Documentation ¶
Index ¶
- Constants
- Variables
- func AddUsersViewers(userID *uuid.UUID, userViewers models.ViewersList, tx *sql.Tx) error
- func ConvertToJSONRaw(references interface{}) (*json.RawMessage, error)
- func DeleteViewerIDsByUserID(userID *uuid.UUID, tx *sql.Tx) error
- func IsPasswordCorrect(password string, user *models.User) bool
- func RollbackWithErrorStack(tx *sql.Tx, errorStack error) error
- type ConnectorCommon
- type DBConnectorMock
- type FunctionsCommon
- type MYSQLConnector
- type MYSQLFunctions
- func (*MYSQLFunctions) AddAsset(assetType string, asset *models.Asset, tx *sql.Tx) error
- func (*MYSQLFunctions) AddProduct(product *models.Product, tx *sql.Tx) error
- func (*MYSQLFunctions) AddProductUsers(productID *uuid.UUID, productUsers *models.ProductUserIDs, tx *sql.Tx) error
- func (*MYSQLFunctions) AddProject(project *models.Project, tx *sql.Tx) error
- func (*MYSQLFunctions) AddProjectUsers(projectID *uuid.UUID, projectUsers *models.ProjectUserIDs, tx *sql.Tx) error
- func (*MYSQLFunctions) AddProjectViewer(projectViewer *models.ProjectViewer, tx *sql.Tx) error
- func (*MYSQLFunctions) AddUser(user *models.User, tx *sql.Tx) error
- func (*MYSQLFunctions) DeleteAsset(assetType string, assetID *uuid.UUID, tx *sql.Tx) error
- func (*MYSQLFunctions) DeleteProduct(productID *uuid.UUID, tx *sql.Tx) error
- func (MYSQLFunctions) DeleteProductUser(productID *uuid.UUID, userID *uuid.UUID, tx *sql.Tx) error
- func (*MYSQLFunctions) DeleteProductUsersByProductID(productID *uuid.UUID, tx *sql.Tx) error
- func (*MYSQLFunctions) DeleteProject(projectID *uuid.UUID, tx *sql.Tx) error
- func (*MYSQLFunctions) DeleteProjectUsersByProjectID(projectID *uuid.UUID, tx *sql.Tx) error
- func (*MYSQLFunctions) DeleteProjectViewerByProjectID(projectID *uuid.UUID, tx *sql.Tx) error
- func (f *MYSQLFunctions) DeleteProjectViewerByUserID(userID *uuid.UUID, tx *sql.Tx) error
- func (*MYSQLFunctions) DeleteProjectViewerByViewerID(viewerID *uuid.UUID, tx *sql.Tx) error
- func (*MYSQLFunctions) DeleteProjectsByProductID(productID *uuid.UUID, tx *sql.Tx) error
- func (*MYSQLFunctions) DeleteUser(ID *uuid.UUID, tx *sql.Tx) error
- func (*MYSQLFunctions) DeleteViewerByOwnerID(userID *uuid.UUID, tx *sql.Tx) error
- func (f *MYSQLFunctions) EmailExists(email string) (bool, error)
- func (f *MYSQLFunctions) GetAsset(assetType string, assetID *uuid.UUID) (*models.Asset, error)
- func (*MYSQLFunctions) GetAssets(assetType string, IDs []uuid.UUID, tx *sql.Tx) ([]models.Asset, error)
- func (f *MYSQLFunctions) GetPrivilege(name string) (*models.Privilege, error)
- func (f *MYSQLFunctions) GetPrivileges() (models.Privileges, error)
- func (*MYSQLFunctions) GetProductByID(ID *uuid.UUID, tx *sql.Tx) (*models.Product, error)
- func (*MYSQLFunctions) GetProductByName(name string, tx *sql.Tx) (*models.Product, error)
- func (*MYSQLFunctions) GetProductProjects(productID *uuid.UUID, tx *sql.Tx) ([]models.Project, error)
- func (MYSQLFunctions) GetProductUserIDs(productID *uuid.UUID, tx *sql.Tx) (*models.ProductUserIDs, error)
- func (*MYSQLFunctions) GetProductsByIDs(IDs []uuid.UUID, tx *sql.Tx) ([]models.Product, error)
- func (*MYSQLFunctions) GetProjectByID(ID *uuid.UUID, tx *sql.Tx) (*models.Project, error)
- func (*MYSQLFunctions) GetProjectViewersByUserID(userID *uuid.UUID, tx *sql.Tx) ([]models.ProjectViewer, error)
- func (*MYSQLFunctions) GetProjectViewersByViewerID(viewerID *uuid.UUID, tx *sql.Tx) ([]models.ProjectViewer, error)
- func (*MYSQLFunctions) GetProjectsByIDs(IDs []uuid.UUID, tx *sql.Tx) ([]models.Project, error)
- func (*MYSQLFunctions) GetUser(queryType int, keyValue interface{}, tx *sql.Tx) (*models.User, error)
- func (f *MYSQLFunctions) GetUserIDsByViewerID(viewerID *uuid.UUID) (*models.ViewUsers, error)
- func (*MYSQLFunctions) GetUserProductIDs(userID *uuid.UUID, tx *sql.Tx) (*models.UserProductIDs, error)
- func (*MYSQLFunctions) GetUserProjectIDs(userID *uuid.UUID, tx *sql.Tx) (*models.UserProjectIDs, error)
- func (MYSQLFunctions) GetUsersByIDs(IDs []uuid.UUID, tx *sql.Tx) ([]models.User, error)
- func (f *MYSQLFunctions) GetViewerIDsByUserID(userID *uuid.UUID) (models.ViewersList, error)
- func (f *MYSQLFunctions) UpdateAsset(assetType string, asset *models.Asset) error
- func (*MYSQLFunctions) UpdateUsersProducts(userID *uuid.UUID, productID *uuid.UUID, privilege int, tx *sql.Tx) error
- func (*MYSQLFunctions) UpdateUsersProjects(userID *uuid.UUID, projectID *uuid.UUID, privilege int, tx *sql.Tx) error
- func (f *MYSQLFunctions) UserExists(username string) (bool, error)
Constants ¶
const ( UserAssets = "user_assets" ProductAssets = "product_assets" ProductDetails = "product_details" UserSettings = "user_settings" ProjectDetails = "project_details" ProjectAssets = "project_assets" )
const ( ByEmail = iota ByID )
Defines the possible user query key names
Variables ¶
var AddAssetQuery = "INSERT INTO %s (id, data) VALUES (UUID_TO_BIN(?), ?)"
var AddProductQuery = "" /* 129-byte string literal not displayed */
var AddProductUsersQuery = "INSERT INTO users_products (users_id, products_id, privileges_id) VALUES (UUID_TO_BIN(?), UUID_TO_BIN(?), ?)"
var AddProjectQuery = "" /* 149-byte string literal not displayed */
var AddProjectUsersQuery = "INSERT INTO users_projects (users_id, projects_id, privileges_id) VALUES (UUID_TO_BIN(?), UUID_TO_BIN(?), ?)"
var AddProjectViewerQuery = "INSERT INTO users_viewers (users_id, viewer_id, projects_id) VALUES (UUID_TO_BIN(?), UUID_TO_BIN(?), UUID_TO_BIN(?))"
var AddUsersViewersQuery = "" /* 129-byte string literal not displayed */
var AddViewerQuery = "INSERT INTO viewers (id, owner_id) VALUES (UUID_TO_BIN(?), UUID_TO_BIN(?))"
var DeleteAssetQuery = "DELETE FROM %s WHERE id=UUID_TO_BIN(?)"
var DeleteProductQuery = "DELETE FROM products where id = UUID_TO_BIN(?)"
var DeleteProductUserQuery = "DELETE FROM users_products where products_id = UUID_TO_BIN(?) AND users_id = UUID_TO_BIN(?)"
var DeleteProductUsersByProductIDQuery = "DELETE FROM users_products where products_id = UUID_TO_BIN(?)"
var DeleteProjectQuery = "DELETE FROM projects where id = UUID_TO_BIN(?)"
var DeleteProjectUsersByProjectIDQuery = "DELETE FROM users_projects where projects_id = UUID_TO_BIN(?)"
var DeleteProjectViewerByProjectIDQuery = "DELETE FROM users_viewers where projects_id = UUID_TO_BIN(?)"
var DeleteProjectViewerByUserIDQuery = "DELETE FROM users_viewers where users_id = UUID_TO_BIN(?)"
var DeleteProjectViewerByViewerIDQuery = "DELETE FROM users_viewers where viewer_id = UUID_TO_BIN(?)"
var DeleteProjectsByProductIDQuery = "DELETE FROM projects where products_id = UUID_TO_BIN(?)"
var DeleteUserQuery = "DELETE FROM users WHERE id=UUID_TO_BIN(?)"
var DeleteViewerByOwnerQuery = "DELETE FROM viewers where owner_id = UUID_TO_BIN(?)"
var DeleteViewerIDsByUserIDQuery = "DELETE FROM users_viewers where users_id = UUID_TO_BIN(?)"
var ErrAssetMissing = "This %s is missing or old value is the same as new"
var ErrDuplicateProductNameEntry = errors.New("Product with this name already exists")
var ErrDuplicateUserNameEntry = errors.New("User with this name already exists")
var ErrNoProductDeleted = errors.New("No product was deleted")
var ErrNoProductUserAdded = errors.New("No product user relation has been added")
var ErrNoProjectDeleted = errors.New("No project was deleted")
var ErrNoProjectUserAdded = errors.New("No project user relation has been added")
var ErrNoProjectViewerDeleted = errors.New("No project viewer was deleted")
var ErrNoUserDeleted = errors.New("No user was deleted")
var ErrNoUserViewerAdded = errors.New("No data views have been added for this user")
var ErrNoUserWithEmail = errors.New("There is no user associated with this email")
var ErrNoUserWithProduct = errors.New("No user is associated to this product")
var ErrNoUserWithProject = errors.New("No user is associated to this project")
var ErrNoUsersProductUpdate = errors.New("No users product was updated")
var ErrNoUsersProjectUpdate = errors.New("No users project was updated")
var ErrNoViewForThisUser = errors.New("No data views associated with this user")
var ErrNoViewerDeleted = errors.New("No viewer was deleted")
var ErrSQLDuplicateEmailEntryString = "Error 1062: Duplicate entry '%s' for key 'users.email'"
var ErrSQLDuplicateProductNameEntryString = "Duplicate entry '%s' for key 'products.name'"
var ErrSQLDuplicateUserNameEntryString = "Error 1062: Duplicate entry '%s' for key 'users.name'"
var GetAssetQuery = "SELECT BIN_TO_UUID(id), data FROM %s WHERE id = UUID_TO_BIN(?)"
var GetAssetsQuery = "SELECT BIN_TO_UUID(id), data FROM %s WHERE id IN (UUID_TO_BIN(?)"
var GetPrivilegeQuery = "SELECT id, name, description from privileges where name = ?"
var GetPrivilegesQuery = "SELECT id, name, description from privileges"
var GetProductByIDQuery = "" /* 133-byte string literal not displayed */
var GetProductByNameQuery = "SELECT BIN_TO_UUID(id), name, BIN_TO_UUID(product_details_id), BIN_TO_UUID(product_assets_id) FROM products WHERE name = ?"
var GetProductProjectsQuery = "" /* 162-byte string literal not displayed */
var GetProductUserIDsQuery = "SELECT BIN_TO_UUID(users_id), privileges_id FROM users_products where products_id = UUID_TO_BIN(?)"
var GetProductsByIDsQuery = "" /* 135-byte string literal not displayed */
var GetProjectByIDQuery = "" /* 153-byte string literal not displayed */
var GetProjectViewerByUserIDQuery = "" /* 129-byte string literal not displayed */
var GetProjectViewerByViewerIDQuery = "" /* 130-byte string literal not displayed */
var GetProjectsByIDsQuery = "" /* 155-byte string literal not displayed */
var GetUserByEmailQuery = "" /* 132-byte string literal not displayed */
var GetUserByIDQuery = "" /* 142-byte string literal not displayed */
var GetUserIDsByViewerIDQuery = "SELECT BIN_TO_UUID(users_id), is_owner from users_viewers where viewer_id = UUID_TO_BIN(?)"
var GetUserProductIDsQuery = "SELECT BIN_TO_UUID(products_id), privileges_id FROM users_products where users_id = UUID_TO_BIN(?)"
var GetUserProjectIDsQuery = "SELECT BIN_TO_UUID(projects_id), privileges_id FROM users_projects where users_id = UUID_TO_BIN(?)"
var GetUsersByIDsQuery = "" /* 144-byte string literal not displayed */
var GetViewerIDsByUserIDQuery = "SELECT BIN_TO_UUID(viewer_id), is_owner, BIN_TO_UUID(projects_id) from users_viewers where users_id = UUID_TO_BIN(?)"
var InsertUserQuery = "" /* 144-byte string literal not displayed */
var UpdateAssetQuery = "UPDATE %s set data = ? where id = UUID_TO_BIN(?)"
var UpdateUsersProductsQuery = "UPDATE users_products set privileges_id = ? where users_id = UUID_TO_BIN(?) AND products_id = UUID_TO_BIN(?)"
var UpdateUsersProjectsQuery = "UPDATE users_projects set privileges_id = ? where users_id = UUID_TO_BIN(?) AND projects_id = UUID_TO_BIN(?)"
Functions ¶
func AddUsersViewers ¶ added in v0.0.9
func ConvertToJSONRaw ¶ added in v0.0.3
func ConvertToJSONRaw(references interface{}) (*json.RawMessage, error)
func DeleteViewerIDsByUserID ¶ added in v0.0.9
func IsPasswordCorrect ¶ added in v0.0.3
CheckPassword compares the password entered by the user with the stored password.
Types ¶
type ConnectorCommon ¶ added in v0.0.10
type ConnectorCommon interface { BootstrapSystem() error ConnectSystem() (*sql.Tx, error) Commit(tx *sql.Tx) error Rollback(tx *sql.Tx) error }
Common interface for DB connection. Needed in order to allow mock and custom DB interface implementation.
type DBConnectorMock ¶ added in v0.0.7
func (*DBConnectorMock) BootstrapSystem ¶ added in v0.0.7
func (*DBConnectorMock) BootstrapSystem() error
func (*DBConnectorMock) ConnectSystem ¶ added in v0.0.7
func (i *DBConnectorMock) ConnectSystem() (*sql.Tx, error)
type FunctionsCommon ¶ added in v0.0.10
type FunctionsCommon interface { GetUser(queryType int, keyValue interface{}, tx *sql.Tx) (*models.User, error) AddUser(user *models.User, tx *sql.Tx) error DeleteUser(userID *uuid.UUID, tx *sql.Tx) error GetProductUserIDs(productID *uuid.UUID, tx *sql.Tx) (*models.ProductUserIDs, error) GetUsersByIDs(IDs []uuid.UUID, tx *sql.Tx) ([]models.User, error) AddAsset(assetType string, asset *models.Asset, tx *sql.Tx) error DeleteAsset(assetType string, assetID *uuid.UUID, tx *sql.Tx) error GetAssets(assetType string, IDs []uuid.UUID, tx *sql.Tx) ([]models.Asset, error) GetAsset(assetType string, assetID *uuid.UUID) (*models.Asset, error) UpdateAsset(assetType string, asset *models.Asset) error UpdateUsersProducts(userID *uuid.UUID, productID *uuid.UUID, privilege int, tx *sql.Tx) error AddProductUsers(productID *uuid.UUID, productUsers *models.ProductUserIDs, tx *sql.Tx) error DeleteProductUsersByProductID(productID *uuid.UUID, tx *sql.Tx) error DeleteProductUser(productID *uuid.UUID, userID *uuid.UUID, tx *sql.Tx) error GetUserProductIDs(userID *uuid.UUID, tx *sql.Tx) (*models.UserProductIDs, error) GetProductByID(ID *uuid.UUID, tx *sql.Tx) (*models.Product, error) GetProductByName(name string, tx *sql.Tx) (*models.Product, error) AddProduct(product *models.Product, tx *sql.Tx) error DeleteProduct(productID *uuid.UUID, tx *sql.Tx) error GetProductsByIDs(IDs []uuid.UUID, tx *sql.Tx) ([]models.Product, error) AddProject(project *models.Project, tx *sql.Tx) error AddProjectUsers(projectID *uuid.UUID, projectUsers *models.ProjectUserIDs, tx *sql.Tx) error GetProjectByID(ID *uuid.UUID, tx *sql.Tx) (*models.Project, error) DeleteProjectUsersByProjectID(projectID *uuid.UUID, tx *sql.Tx) error DeleteProject(projectID *uuid.UUID, tx *sql.Tx) error DeleteProjectsByProductID(productID *uuid.UUID, tx *sql.Tx) error GetProjectsByIDs(IDs []uuid.UUID, tx *sql.Tx) ([]models.Project, error) GetProductProjects(productID *uuid.UUID, tx *sql.Tx) ([]models.Project, error) GetUserProjectIDs(userID *uuid.UUID, tx *sql.Tx) (*models.UserProjectIDs, error) UpdateUsersProjects(userID *uuid.UUID, projectID *uuid.UUID, privilege int, tx *sql.Tx) error AddProjectViewer(projectViewer *models.ProjectViewer, tx *sql.Tx) error DeleteProjectViewerByUserID(userID *uuid.UUID, tx *sql.Tx) error GetProjectViewersByUserID(userID *uuid.UUID, tx *sql.Tx) ([]models.ProjectViewer, error) GetProjectViewersByViewerID(viewerID *uuid.UUID, tx *sql.Tx) ([]models.ProjectViewer, error) DeleteProjectViewerByViewerID(viewerID *uuid.UUID, tx *sql.Tx) error DeleteProjectViewerByProjectID(projectID *uuid.UUID, tx *sql.Tx) error DeleteViewerByOwnerID(userID *uuid.UUID, tx *sql.Tx) error GetPrivileges() (models.Privileges, error) GetPrivilege(name string) (*models.Privilege, error) }
Data handling common function interface. Needed in order to allow mock and custom functionality implementations.
type MYSQLConnector ¶ added in v0.0.7
MYSQL database connector implementation
func (*MYSQLConnector) BootstrapSystem ¶ added in v0.0.7
func (c *MYSQLConnector) BootstrapSystem() error
func (*MYSQLConnector) ConnectSystem ¶ added in v0.0.7
func (c *MYSQLConnector) ConnectSystem() (*sql.Tx, error)
type MYSQLFunctions ¶ added in v0.0.7
type MYSQLFunctions struct { DBConnector ConnectorCommon UUIDImpl models.UUIDCommon }
MYSQLFunctions represents the implementation of MYSQL data manipulation functions.
var DBFunctions *MYSQLFunctions
func (*MYSQLFunctions) AddProduct ¶ added in v0.0.7
func (*MYSQLFunctions) AddProductUsers ¶ added in v0.0.7
func (*MYSQLFunctions) AddProductUsers(productID *uuid.UUID, productUsers *models.ProductUserIDs, tx *sql.Tx) error
func (*MYSQLFunctions) AddProject ¶ added in v0.0.9
func (*MYSQLFunctions) AddProjectUsers ¶ added in v0.0.9
func (*MYSQLFunctions) AddProjectUsers(projectID *uuid.UUID, projectUsers *models.ProjectUserIDs, tx *sql.Tx) error
func (*MYSQLFunctions) AddProjectViewer ¶ added in v0.0.21
func (*MYSQLFunctions) AddProjectViewer(projectViewer *models.ProjectViewer, tx *sql.Tx) error
func (*MYSQLFunctions) AddUser ¶ added in v0.0.7
AddUser creates a new user entry in the DB. Whitespaces in the email are automatically deleted Email/Name are unique in DB. Duplicates will return error.
func (*MYSQLFunctions) DeleteAsset ¶ added in v0.0.7
func (*MYSQLFunctions) DeleteProduct ¶ added in v0.0.7
func (MYSQLFunctions) DeleteProductUser ¶ added in v0.0.9
func (*MYSQLFunctions) DeleteProductUsersByProductID ¶ added in v0.0.7
func (*MYSQLFunctions) DeleteProject ¶ added in v0.0.9
func (*MYSQLFunctions) DeleteProjectUsersByProjectID ¶ added in v0.0.9
func (*MYSQLFunctions) DeleteProjectViewerByProjectID ¶ added in v0.0.21
func (*MYSQLFunctions) DeleteProjectViewerByUserID ¶ added in v0.0.21
func (*MYSQLFunctions) DeleteProjectViewerByViewerID ¶ added in v0.0.21
func (*MYSQLFunctions) DeleteProjectsByProductID ¶ added in v0.0.9
func (*MYSQLFunctions) DeleteUser ¶ added in v0.0.7
func (*MYSQLFunctions) DeleteViewerByOwnerID ¶ added in v0.0.21
func (*MYSQLFunctions) EmailExists ¶ added in v0.0.10
func (f *MYSQLFunctions) EmailExists(email string) (bool, error)
func (*MYSQLFunctions) GetPrivilege ¶ added in v0.0.9
func (f *MYSQLFunctions) GetPrivilege(name string) (*models.Privilege, error)
func (*MYSQLFunctions) GetPrivileges ¶ added in v0.0.7
func (f *MYSQLFunctions) GetPrivileges() (models.Privileges, error)
func (*MYSQLFunctions) GetProductByID ¶ added in v0.0.7
func (*MYSQLFunctions) GetProductByName ¶ added in v0.0.7
func (*MYSQLFunctions) GetProductProjects ¶ added in v0.0.12
func (MYSQLFunctions) GetProductUserIDs ¶ added in v0.0.9
func (MYSQLFunctions) GetProductUserIDs(productID *uuid.UUID, tx *sql.Tx) (*models.ProductUserIDs, error)
func (*MYSQLFunctions) GetProductsByIDs ¶ added in v0.0.9
func (*MYSQLFunctions) GetProjectByID ¶ added in v0.0.9
func (*MYSQLFunctions) GetProjectViewersByUserID ¶ added in v0.0.21
func (*MYSQLFunctions) GetProjectViewersByUserID(userID *uuid.UUID, tx *sql.Tx) ([]models.ProjectViewer, error)
func (*MYSQLFunctions) GetProjectViewersByViewerID ¶ added in v0.0.21
func (*MYSQLFunctions) GetProjectViewersByViewerID(viewerID *uuid.UUID, tx *sql.Tx) ([]models.ProjectViewer, error)
func (*MYSQLFunctions) GetProjectsByIDs ¶ added in v0.0.9
func (*MYSQLFunctions) GetUser ¶ added in v0.0.7
func (*MYSQLFunctions) GetUser(queryType int, keyValue interface{}, tx *sql.Tx) (*models.User, error)
GetUser returns the user defined by the key name and key value. Key name can be either id or email.
func (*MYSQLFunctions) GetUserIDsByViewerID ¶ added in v0.0.10
func (*MYSQLFunctions) GetUserProductIDs ¶ added in v0.0.7
func (*MYSQLFunctions) GetUserProductIDs(userID *uuid.UUID, tx *sql.Tx) (*models.UserProductIDs, error)
func (*MYSQLFunctions) GetUserProjectIDs ¶ added in v0.0.9
func (*MYSQLFunctions) GetUserProjectIDs(userID *uuid.UUID, tx *sql.Tx) (*models.UserProjectIDs, error)
func (MYSQLFunctions) GetUsersByIDs ¶ added in v0.0.9
func (*MYSQLFunctions) GetViewerIDsByUserID ¶ added in v0.0.10
func (f *MYSQLFunctions) GetViewerIDsByUserID(userID *uuid.UUID) (models.ViewersList, error)
func (*MYSQLFunctions) UpdateAsset ¶ added in v0.0.10
func (f *MYSQLFunctions) UpdateAsset(assetType string, asset *models.Asset) error
func (*MYSQLFunctions) UpdateUsersProducts ¶ added in v0.0.7
func (*MYSQLFunctions) UpdateUsersProjects ¶ added in v0.0.9
func (*MYSQLFunctions) UserExists ¶ added in v0.0.10
func (f *MYSQLFunctions) UserExists(username string) (bool, error)