Documentation
¶
Index ¶
- Constants
- Variables
- func AddProject(project models.Project) error
- func ConvertToJSONRaw(references interface{}) (*json.RawMessage, error)
- func EmailExists(email string) (bool, error)
- func GetAsset(assetType string, assetID *uuid.UUID) (*models.Asset, error)
- func GetProjectByName(name string) (*models.Project, error)
- func IsPasswordCorrect(password string, user *models.User) bool
- func RollbackWithErrorStack(tx *sql.Tx, errorStack error) error
- func UpdateAsset(assetType string, asset *models.Asset) error
- func UpdateProject(project models.Project) error
- func UserExists(username string) (bool, error)
- type DBConnectorCommon
- type DBConnectorMock
- type FunctionCommonInterface
- 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.ProductUsers, 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) DeleteProductUsersByProductID(productID *uuid.UUID, tx *sql.Tx) error
- func (*MYSQLFunctions) DeleteUser(ID *uuid.UUID, tx *sql.Tx) error
- func (*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) GetProductsByUserID(userID uuid.UUID) ([]models.Product, error)
- func (*MYSQLFunctions) GetUser(queryString string, keyValue interface{}, tx *sql.Tx) (*models.User, error)
- func (*MYSQLFunctions) GetUserProductIDs(userID uuid.UUID, tx *sql.Tx) (*models.UserProducts, error)
- func (MYSQLFunctions) UpdateUsersProducts(userID *uuid.UUID, productID *uuid.UUID, privilege int, tx *sql.Tx) error
Constants ¶
const ( UserAssets = "user_assets" ProductAssets = "product_assets" ProductDetails = "product_details" UserSettings = "user_settings" )
const ( ByEmail = "email" ByID = "id" )
Defines the possible user query key names
Variables ¶
var AddAssetQuery = "INSERT INTO ? (id, data) VALUES (UUID_TO_BIN(?), ?)"
var AddProductQuery = "INSERT INTO products (id, name, public, product_details_id, product_assets_id) VALUES (UUID_TO_BIN(?), ?, ?, ?, ?)"
var AddProductUsersQuery = "INSERT INTO users_products (users_id, products_id, privilege) VALUES (UUID_TO_BIN(?), UUID_TO_BIN(?), ?)"
var DBConnection = ""
var DeleteAssetQuery = "DELETE FROM ? WHERE id=UUID_TO_BIN(?)"
var DeleteProductQuery = "DELETE FROM products where id = UUID_TO_BIN(?)"
var DeleteProductUsersByProductIDQuery = "DELETE FROM users_products where products_id = UUID_TO_BIN(?)"
var DeleteUserQuery = "DELETE FROM users WHERE id=UUID_TO_BIN(?)"
var ErrAssetMissing = "This %s is missing"
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 ErrNoProductsForUser = errors.New("This user has no products")
var ErrNoUserDeleted = errors.New("No user was deleted")
var ErrNoUserWithEmail = errors.New("There is no user associated with this email")
var ErrNoUserWithProduct = errors.New("No user is associated to this product")
var ErrNoUsersProductUpdate = errors.New("No users product was updated")
var ErrSQLDuplicateEmailEntryString = "Duplicate entry '%s' for key 'users.email'"
var ErrSQLDuplicateProductNameEntryString = "Duplicate entry '%s' for key 'products.name'"
var ErrSQLDuplicateUserNameEntryString = "Duplicate entry '%s' for key 'users.name'"
var GetPrivilegesQuery = "SELECT id, name, description from privileges"
var GetProductByIDQuery = "SELECT BIN_TO_UUID(id), name, public, details, BIN_TO_UUID(product_assets_id) FROM products WHERE id = UUID_TO_BIN(?)"
var GetProductByNameQuery = "SELECT BIN_TO_UUID(id), name, public, details, BIN_TO_UUID(product_assests_id) FROM products WHERE name = ?"
var GetUserByEmailQuery = "" /* 132-byte string literal not displayed */
var GetUserByIDQuery = "" /* 142-byte string literal not displayed */
var GetUserProductIDsQuery = "SELECT BIN_TO_UUID(products_id), privilege FROM users_products where users_id = UUID_TO_BIN(?)"
var InsertUserQuery = "" /* 144-byte string literal not displayed */
var MigrationDirectory = ""
var UpdateUsersProductsQuery = "UPDATE users_products set privilege = ? where users_id = UUID_TO_BIN(?) AND products_id = UUID_TO_BIN(?)"
Functions ¶
func AddProject ¶ added in v0.0.3
AddProject adds a new project to the database.
func ConvertToJSONRaw ¶ added in v0.0.3
func ConvertToJSONRaw(references interface{}) (*json.RawMessage, error)
func EmailExists ¶
func GetProjectByName ¶ added in v0.0.3
GetProjectByName returns the project by name.
func IsPasswordCorrect ¶ added in v0.0.3
CheckPassword compares the password entered by the user with the stored password.
func RollbackWithErrorStack ¶ added in v0.0.6
func UpdateProject ¶ added in v0.0.3
UpdateProject updates the selected project.
func UserExists ¶
Types ¶
type DBConnectorCommon ¶ added in v0.0.7
type DBConnectorCommon interface { BootstrapSystem() error ConnectSystem() (*sql.Tx, error) Commit(tx *sql.Tx) error }
Common interface for DB connection. Needed in order to allow mock and custom DB interface implementation.
var DBConnector DBConnectorCommon
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 FunctionCommonInterface ¶ added in v0.0.7
type FunctionCommonInterface interface { GetUser(queryString string, keyValue interface{}, tx *sql.Tx) (*models.User, error) AddUser(user *models.User, tx *sql.Tx) error DeleteUser(userID *uuid.UUID, tx *sql.Tx) error AddAsset(assetType string, asset *models.Asset, tx *sql.Tx) error DeleteAsset(assetType string, assetID *uuid.UUID, tx *sql.Tx) error GetProductsByUserID(userID uuid.UUID) ([]models.Product, error) UpdateUsersProducts(userID *uuid.UUID, productID *uuid.UUID, privilege int, tx *sql.Tx) error AddProductUsers(productID *uuid.UUID, productUsers models.ProductUsers, tx *sql.Tx) error DeleteProductUsersByProductID(productID *uuid.UUID, tx *sql.Tx) error GetUserProductIDs(userID uuid.UUID, tx *sql.Tx) (*models.UserProducts, 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 GetPrivileges() (models.Privileges, error) }
Data handling common function interface. Needed in order to allow mock and custom functionality implementations.
var Functions FunctionCommonInterface
type MYSQLConnector ¶ added in v0.0.7
type MYSQLConnector struct { }
MYSQL Interface implementation
func (*MYSQLConnector) BootstrapSystem ¶ added in v0.0.7
func (*MYSQLConnector) BootstrapSystem() error
func (*MYSQLConnector) ConnectSystem ¶ added in v0.0.7
func (*MYSQLConnector) ConnectSystem() (*sql.Tx, error)
type MYSQLFunctions ¶ added in v0.0.7
type MYSQLFunctions struct { }
MYSQL Interface implementation
func (*MYSQLFunctions) AddProduct ¶ added in v0.0.7
func (MYSQLFunctions) AddProductUsers ¶ added in v0.0.7
func (MYSQLFunctions) AddProductUsers(productID *uuid.UUID, productUsers models.ProductUsers, 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) DeleteProductUsersByProductID ¶ added in v0.0.7
func (*MYSQLFunctions) DeleteUser ¶ added in v0.0.7
func (*MYSQLFunctions) GetPrivileges ¶ added in v0.0.7
func (*MYSQLFunctions) GetPrivileges() (models.Privileges, error)
func (*MYSQLFunctions) GetProductByID ¶ added in v0.0.7
func (*MYSQLFunctions) GetProductByName ¶ added in v0.0.7
func (*MYSQLFunctions) GetProductsByUserID ¶ added in v0.0.7
GetProductsByUserID returns all products belonging to the selected user. The function first gets all rows matching with the user DI from users_products table, then gets all products based on the product ids from the first query result.
func (*MYSQLFunctions) GetUser ¶ added in v0.0.7
func (*MYSQLFunctions) GetUser(queryString string, 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) GetUserProductIDs ¶ added in v0.0.7
func (*MYSQLFunctions) GetUserProductIDs(userID uuid.UUID, tx *sql.Tx) (*models.UserProducts, error)