Shift to master. Not done but database abstraction is nearly done. #3
|
@ -4,6 +4,10 @@ RecipeDatabase::RecipeDatabase(string filename) : Database(filename){
|
||||||
this->ensureTablesExist();
|
this->ensureTablesExist();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RecipeDatabase::storeRecipe(Recipe recipe){
|
||||||
|
///TODO: Implement this in a smart way using transaction.
|
||||||
|
}
|
||||||
|
|
||||||
void RecipeDatabase::ensureTablesExist(){
|
void RecipeDatabase::ensureTablesExist(){
|
||||||
//Make sure that foreign keys are enabled.
|
//Make sure that foreign keys are enabled.
|
||||||
this->executeSQL("PRAGMA foreign_keys = ON;");
|
this->executeSQL("PRAGMA foreign_keys = ON;");
|
||||||
|
@ -47,7 +51,7 @@ void RecipeDatabase::ensureTablesExist(){
|
||||||
"quantity real,"
|
"quantity real,"
|
||||||
"unitName varchar,"
|
"unitName varchar,"
|
||||||
"comment varchar,"
|
"comment varchar,"
|
||||||
"PRIMARY KEY (ingredientId, recipeId),"
|
"PRIMARY KEY (recipeId),"
|
||||||
"FOREIGN KEY (ingredientId) REFERENCES ingredient(ingredientId),"
|
"FOREIGN KEY (ingredientId) REFERENCES ingredient(ingredientId),"
|
||||||
"FOREIGN KEY (recipeId) REFERENCES recipe(recipeId));");
|
"FOREIGN KEY (recipeId) REFERENCES recipe(recipeId));");
|
||||||
//Recipe Instruction mapping table.
|
//Recipe Instruction mapping table.
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
|
|
||||||
#include "database.h"
|
#include "database.h"
|
||||||
|
#include "model/recipe/recipe.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
@ -15,6 +16,9 @@ class RecipeDatabase : public Database
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
RecipeDatabase(string filename);
|
RecipeDatabase(string filename);
|
||||||
|
|
||||||
|
//Stores a full recipe in the database.
|
||||||
|
void storeRecipe(Recipe recipe);
|
||||||
private:
|
private:
|
||||||
|
|
||||||
//Utility methods.
|
//Utility methods.
|
||||||
|
|
Loading…
Reference in New Issue