Documentation ¶
Overview ¶
Package statements provides SQLite statements for the service.
Index ¶
- Constants
- Variables
- func BuildBaseSelectRecipe(sorts models.Sort) string
- func BuildSelectNutrientFDC(ingredients []string) string
- func BuildSelectPaginatedResults(queries []string, page uint64, options models.SearchOptionsRecipes) string
- func BuildSelectSearchResultsCount(queries []string, options models.SearchOptionsRecipes) string
Constants ¶
const DeleteAuthToken = `
DELETE
FROM auth_tokens
WHERE user_id = ?`
DeleteAuthToken removes the authentication token associated with the user id from the database.
const DeleteCookbook = `
DELETE
FROM cookbooks
WHERE id = ?
AND user_id = ?`
DeleteCookbook deletes a user's cookbook.
const DeleteCookbookRecipe = `` /* 128-byte string literal not displayed */
DeleteCookbookRecipe deletes a recipe from a user's cookbook.
const DeleteCookbooks = `
DELETE
FROM cookbooks
WHERE user_id = ?`
DeleteCookbooks deletes all the user's cookbooks.
const DeleteRecipe = `` /* 133-byte string literal not displayed */
DeleteRecipe deletes a user's recipe and the recipe itself.
const DeleteRecipeIngredients = `
DELETE
FROM ingredient_recipe
WHERE recipe_id = ?`
DeleteRecipeIngredients deletes all ingredients from a recipe.
const DeleteRecipeInstructions = `
DELETE
FROM instruction_recipe
WHERE recipe_id = ?`
DeleteRecipeInstructions deletes all instructions from a recipe.
const DeleteRecipesUser = `
DELETE
FROM recipes
WHERE id IN (SELECT recipe_id
FROM user_recipe
WHERE user_id = ?)`
DeleteRecipesUser deletes the user's recipes.
const DeleteUser = `
DELETE
FROM users
WHERE id = ?`
DeleteUser deletes a user from the users table.
const InsertAuthToken = `
INSERT INTO auth_tokens (selector, hash_validator, user_id)
VALUES (?, ?, ?)`
InsertAuthToken is the query to add an authentication token to the database.
const InsertCategory = `
INSERT INTO categories (name)
VALUES (?)
ON CONFLICT DO UPDATE SET name = EXCLUDED.name
RETURNING id`
InsertCategory is the query to add a category to the database.
const InsertCookbook = `
INSERT INTO cookbooks (title, image, user_id)
VALUES (?, ?, ?)
RETURNING id`
InsertCookbook is the query to add a cookbook to the database.
const InsertCookbookRecipe = `` /* 241-byte string literal not displayed */
InsertCookbookRecipe is the query to add a recipe to a cookbook.
const InsertCuisine = `
INSERT OR IGNORE INTO cuisines (name)
VALUES (?)`
InsertCuisine is the query to add a cuisine to the database
const InsertIngredient = `
INSERT INTO ingredients (name)
VALUES (?)
ON CONFLICT (name) DO UPDATE SET name = EXCLUDED.name
RETURNING id`
InsertIngredient is the query to add an ingredient.
const InsertInstruction = `
INSERT INTO instructions (name)
VALUES (?)
ON CONFLICT (name)
DO UPDATE SET name = EXCLUDED.name
RETURNING id`
InsertInstruction is the query to add an instruction.
const InsertKeyword = `
INSERT INTO keywords (name)
VALUES (?)
ON CONFLICT (name)
DO UPDATE SET name = EXCLUDED.name
RETURNING id`
InsertKeyword is the query to add a keyword.
const InsertNutrition = `` /* 215-byte string literal not displayed */
InsertNutrition is the query to add a nutrition facts.
const InsertRecipe = `
INSERT INTO recipes (name, description, image, yield, url)
VALUES (?, ?, ?, ?, ?)
RETURNING id`
InsertRecipe is the query to add a recipe to the database.
const InsertRecipeCategory = `
INSERT INTO category_recipe (category_id, recipe_id)
VALUES (?, ?)`
InsertRecipeCategory associates a recipe with a category.
const InsertRecipeCuisine = `
INSERT INTO cuisine_recipe (cuisine_id, recipe_id)
VALUES (?, ?)`
InsertRecipeCuisine associates a recipe with a category.
const InsertRecipeIngredient = `
INSERT INTO ingredient_recipe (ingredient_id, recipe_id, ingredient_order)
VALUES (?, ?, ?)`
InsertRecipeIngredient is the query to associate a recipe with an ingredient.
const InsertRecipeInstruction = `
INSERT INTO instruction_recipe (instruction_id, recipe_id, instruction_order)
VALUES (?, ?, ?)`
InsertRecipeInstruction is the query to associate a recipe with an instruction.
const InsertRecipeKeyword = `
INSERT INTO keyword_recipe (keyword_id, recipe_id)
VALUES (?, ?)`
InsertRecipeKeyword is the query to associate a recipe with a keyword.
const InsertRecipeShadow = `
INSERT OR REPLACE INTO shadow_last_inserted_recipe (row, id, name, description, source)
VALUES (1, ?, ?, ?, ?)`
InsertRecipeShadow is the query to insert a recipe into the shadow table.
const InsertRecipeTime = `
INSERT INTO time_recipe (time_id, recipe_id)
VALUES (?, ?)`
InsertRecipeTime is the query to associate a recipe with a time.
const InsertRecipeTool = `
INSERT INTO tool_recipe (tool_id, recipe_id)
VALUES (?, ?)`
InsertRecipeTool is the query to associate a recipe with a tool.
const InsertReport = `
INSERT INTO reports (report_type, created_at, exec_time_ns, user_id)
VALUES (?, ?, ?, ?)
RETURNING id`
InsertReport is the query to add a report without logs into the database
const InsertReportLog = `
INSERT INTO report_logs (report_id, title, success, error_reason)
VALUES (?, ?, ?, ?)`
InsertReportLog is the query to add a log to a report.
INSERT INTO share_recipes (link, recipe_id, user_id)
VALUES (?, ?, ?)
ON CONFLICT (link, recipe_id) DO NOTHING`InsertShareLink is the query to add a recipe share link to the database.
INSERT INTO share_cookbooks (link, cookbook_id, user_id)
VALUES (?, ?, ?)
ON CONFLICT (link, cookbook_id) DO NOTHING`InsertShareLinkCookbook is the query to add a cookbook share link to the database.
const InsertTimes = `` /* 223-byte string literal not displayed */
InsertTimes is the query to add kitchen times.
const InsertTool = `
INSERT INTO tools (name)
VALUES (?)
ON CONFLICT (name)
DO UPDATE SET name = EXCLUDED.name
RETURNING id`
InsertTool is the query to add a tool.
const InsertUser = `
INSERT INTO users (email, hashed_password)
VALUES (?, ?)
RETURNING id`
InsertUser is the query to add a user to the database.
const InsertUserCategory = `
INSERT OR IGNORE INTO user_category (user_id, category_id)
VALUES (?, ?)`
InsertUserCategory is the query to associate a category with a user.
const InsertUserRecipe = `
INSERT INTO user_recipe (user_id, recipe_id)
VALUES (?, ?)`
InsertUserRecipe is the query to associate a recipe with a user.
const IsRecipeForUserExist = `` /* 251-byte string literal not displayed */
IsRecipeForUserExist checks whether the recipe belongs to the given user.
const SelectAppInfo = `
SELECT is_update_available, updated_at, update_last_checked_at
FROM app
WHERE id = 1`
SelectAppInfo fetches general information on the application.
const SelectAuthToken = `
SELECT id, hash_validator, expires, user_id
FROM auth_tokens
WHERE selector = ?
AND expires > unixepoch('now')`
SelectAuthToken fetches a non-expired auth token by the selector.
const SelectCategories = `
SELECT c.name
FROM user_category AS uc
JOIN categories c ON c.id = uc.category_id
WHERE uc.user_id = ?
ORDER BY name`
SelectCategories fetches a user's recipe categories.
const SelectCookbook = `
SELECT c.id, c.title, c.image, c.count
FROM cookbooks AS c
WHERE id = ?
AND user_id = ?`
SelectCookbook gets a user's cookbook by cookbook ID.
const SelectCookbookExists = `
SELECT EXISTS (SELECT c.id
FROM cookbooks AS c
WHERE id = ?
AND user_id = ?)`
SelectCookbookExists verifies whether the cookbook belongs to the user.
const SelectCookbookRecipe = baseSelectRecipe + `
JOIN cookbook_recipes AS cr ON recipes.id = cr.recipe_id
WHERE cr.cookbook_id = ?
AND cr.recipe_id = ?
GROUP BY recipes.id`
SelectCookbookRecipe fetches a recipe from a cookbook.
const SelectCookbookRecipeExists = `` /* 186-byte string literal not displayed */
SelectCookbookRecipeExists verifies whether the recipe and the cookbook belongs to a user.
const SelectCookbookRecipes = baseSelectRecipe + `
JOIN cookbook_recipes AS cr ON recipes.id = cr.recipe_id
WHERE cr.cookbook_id = ?
GROUP BY recipes.id
ORDER BY cr.order_index`
SelectCookbookRecipes fetches the recipes in a cookbook.
SELECT cookbook_id, user_id
FROM share_cookbooks
WHERE link = ?`SelectCookbookShared gets a shared cookbook link.
SELECT link
FROM share_cookbooks
WHERE cookbook_id = ?
AND user_id = ?`SelectCookbookSharedLink gets the link of a shared cookbook.
const SelectCookbookUser = `
SELECT user_id
FROM cookbooks
WHERE id = ?`
SelectCookbookUser gets the ID of the user who has the cookbook ID.
SELECT link, cookbook_id
FROM share_cookbooks
WHERE user_id = ?`SelectCookbooksShared gets the user's shared cookbooks.
const SelectCookbooksUser = `
SELECT id, title, image, count
FROM cookbooks
WHERE user_id = 2`
SelectCookbooksUser gets all cookbooks belonging to the user.
const SelectCountWebsites = `
SELECT COUNT(id)
FROM websites`
SelectCountWebsites fetches the number of supported websites.
const SelectCounts = `
SELECT cookbooks, recipes
FROM counts
WHERE user_id = ?`
SelectCounts gets the number of recipes and cookbooks belonging to the user.
const SelectCuisineID = `
SELECT id
FROM cuisines
WHERE name = ?`
SelectCuisineID gets the ID of the specified cuisine.
const SelectDistinctImages = `
SELECT DISTINCT image
FROM recipes
UNION
SELECT DISTINCT image
FROM cookbooks`
SelectDistinctImages gets all distinct image UUIDs from the recipes table.
const SelectMeasurementSystems = `` /* 279-byte string literal not displayed */
SelectMeasurementSystems fetches the units systems along with the user's selected system and settings.
const SelectRecipe = baseSelectRecipe + `
INNER JOIN user_recipe AS ur ON ur.recipe_id = recipes.id
WHERE recipes.id = ?
AND ur.user_id = ?
LIMIT 1`
SelectRecipe fetches a user's recipe.
SELECT recipe_id, user_id
FROM share_recipes
WHERE link = ?`SelectRecipeShared checks whether the recipe is shared.
const SelectRecipeUser = `
SELECT user_id
FROM user_recipe
WHERE recipe_id = ?`
SelectRecipeUser fetches the user whose recipe belongs to.
const SelectRecipes = ` WITh results AS ( SELECT recipe_id, name, description,image,created_at,category,row_num FROM ( ` + baseSelectSearchRecipe + ` WHERE user_recipe.user_id = ? GROUP BY recipes.id ) ) SELECT * FROM results WHERE row_num BETWEEN (?-1)*` + templates.ResultsPerPageStr + `+1 AND (?-1)*` + templates.ResultsPerPageStr + `+` + templates.ResultsPerPageStr
SelectRecipes fetches a chunk of the user's recipes.
const SelectRecipesAll = baseSelectRecipe + `
WHERE recipes.id IN (SELECT recipe_id FROM user_recipe WHERE user_id = ?)
GROUP BY recipes.id`
SelectRecipesAll fetches all the user's recipes.
SELECT link, recipe_id
FROM share_recipes
WHERE user_id = ?`SelectRecipesShared gets the recipes the user shared.
const SelectReport = `` /* 132-byte string literal not displayed */
SelectReport fetches the report of the given ID belonging to the user.
const SelectReports = `` /* 231-byte string literal not displayed */
SelectReports fetches the import reports for the user.
const SelectUserEmail = `
SELECT email
FROM users
WHERE id = ?`
SelectUserEmail fetches the user's email from their id.
const SelectUserExist = `
SELECT EXISTS(
SELECT 1
FROM users
WHERE email = ?
)`
SelectUserExist checks whether the user is present.
const SelectUserID = `
SELECT id
FROM users
WHERE email = ?`
SelectUserID fetches the user's id from their email.
const SelectUserOne = `
SELECT id
FROM users
WHERE id = 1`
SelectUserOne fetches the first user.
const SelectUserPassword = `
SELECT id, hashed_password
FROM users
WHERE email = ?`
SelectUserPassword fetches the user's password for verification purposes.
const SelectUserPasswordByID = `
SELECT hashed_password
FROM users
WHERE id = ?`
SelectUserPasswordByID fetches the user's hashed password by their id.
const SelectUserSettings = `` /* 177-byte string literal not displayed */
SelectUserSettings fetchs a user's settings.
const SelectUsers = `
SELECT id, email
FROM users
ORDER BY id`
SelectUsers fetches all users from the database.
const SelectWebsites = `
SELECT id, host, url
FROM websites`
SelectWebsites fetches all websites from the database.
const UpdateCalculateNutrition = `
UPDATE user_settings
SET calculate_nutrition = ?
WHERE user_id = ?`
UpdateCalculateNutrition is the query to update the user's calculate nutrition setting.
const UpdateConvertAutomatically = `
UPDATE user_settings
SET convert_automatically = ?
WHERE user_id = ?`
UpdateConvertAutomatically is the query to update the user's convert automatically setting.
const UpdateCookbookImage = `
UPDATE cookbooks
SET image = ?
WHERE user_id = ?
AND id = ?`
UpdateCookbookImage is the query to update the image of a user's cookbook.
const UpdateCookbookRecipesReorder = `
UPDATE cookbook_recipes
SET order_index = ?
WHERE cookbook_id = ?
AND recipe_id = ?`
UpdateCookbookRecipesReorder is the query to reorder recipes in a cookbook.
const UpdateIsConfirmed = `
UPDATE users
SET is_confirmed = 1
WHERE id = ?`
UpdateIsConfirmed sets the user's account confirmed to true.
const UpdateIsUpdateAvailable = `
UPDATE app
SET is_update_available = ?
WHERE id = 1
RETURNING updated_at, update_last_checked_at`
UpdateIsUpdateAvailable is the query to flag whether a release update is available.
const UpdateMeasurementSystem = `
UPDATE user_settings
SET measurement_system_id = (SELECT id FROM measurement_systems WHERE name = ?)
WHERE user_id = ?`
UpdateMeasurementSystem is the query to update the user's preferred measurement system.
const UpdateNutrition = `` /* 280-byte string literal not displayed */
UpdateNutrition updates the recipe's nutrition.
const UpdatePassword = `
UPDATE users
SET hashed_password = ?, updated_at = CURRENT_TIMESTAMP
WHERE id = ?`
UpdatePassword sets the user's new password.
const UpdateRecipeCategory = `
UPDATE category_recipe
SET category_id = ?
WHERE id = ?`
UpdateRecipeCategory is the query to update a recipe's category.
const UpdateRecipeDescription = `
UPDATE recipes
SET description = ?
WHERE id = ?`
UpdateRecipeDescription is the query to update a recipe's description.
const UpdateRecipeIngredient = `` /* 137-byte string literal not displayed */
UpdateRecipeIngredient is the query to update a recipe's ingredient.
const UpdateRecipeInstruction = `` /* 141-byte string literal not displayed */
UpdateRecipeInstruction is the query to update a recipe's instruction.
const UpdateRecipeTimes = `
UPDATE time_recipe
SET time_id = ?
WHERE recipe_id = ?`
UpdateRecipeTimes is the query to update a recipe's times.
const UpdateUserSettingsCookbooksViewMode = `
UPDATE user_settings
SET cookbooks_view = ?
WHERE user_id = ?`
UpdateUserSettingsCookbooksViewMode is the query to update the cookbooks_view column of a user's settings.
Variables ¶
var RecipesFTSFields = []string{"name", "description", "category", "ingredients", "instructions", "keywords", "source"}
RecipesFTSFields lists all columns in the recipes_fts table.
var SelectCookbooks = ` SELECT id, image, title, count FROM cookbooks WHERE id >= (SELECT id FROM (SELECT id, ROW_NUMBER() OVER (ORDER BY id) AS row_num FROM cookbooks WHERE user_id = ?) WHERE row_num > (? - 1) *` + templates.ResultsPerPageStr + " + " + templates.ResultsPerPageStr + `) AND user_id = ? LIMIT ` + templates.ResultsPerPageStr
SelectCookbooks gets a limited number of cookbooks belonging to the user.
Functions ¶
func BuildBaseSelectRecipe ¶ added in v1.1.0
BuildBaseSelectRecipe builds from the options.
func BuildSelectNutrientFDC ¶
BuildSelectNutrientFDC builds the query to fetch a nutrient from the FDC database.
func BuildSelectPaginatedResults ¶ added in v1.1.0
func BuildSelectPaginatedResults(queries []string, page uint64, options models.SearchOptionsRecipes) string
BuildSelectPaginatedResults builds a SQL query for paginated search results.
func BuildSelectSearchResultsCount ¶ added in v1.1.0
func BuildSelectSearchResultsCount(queries []string, options models.SearchOptionsRecipes) string
BuildSelectSearchResultsCount builds a SQL query for fetching the number of paginated results.
Types ¶
This section is empty.