Working on a recipe type app and I am working on the routes/endpoints/backend. Team wants the following JSON structure for when reaching the GET request.
const fakeDataRecipes = [
{
id:0,
title:"PBJ",
source:"Mother",
ingredients:["bread", "peanut butter", "jam"],
instructions: "1. Get bread. 2. Get peanut butter and jam. 3. Put together.",
category:["snack", "dinner", "vegetarian", "sandwich"],
user_id:1
},
{
id:1,
title:"Peanut Butter and Banana Sandwich",
source:"Uncle Steve",
instructions: "1. Get bread. 2. Get peanut butter. 3. Slice banana. 4. Put together",
ingredients:["bread", "peanut butter", "banana", "chocolate"],
category:["snack", "dinner", "vegetarian", "sandwich"],
user_id:2
}
];
I have searched but I seems SQLITE3 does not support arrays in columns. what is the best approach to this situation? I need ingredients & category to be an array. Some people say Create a new table for the ingredients & category. Others says to use a blob data type in SQLite3 which I am not familiar with. Or Just store it as a string and then then covert it to array which I am not sure would work or create problems for the front end. the following is the knex migration file
exports.up = function(knex) {
return knex.schema.createTable('recipes', recipeColumn=>{
recipeColumn.increments();
recipeColumn.text('title').unique().notNullable();
recipeColumn.text('source').unique().notNullable();
})
};