Express JS - adding a route within a server to handle POST requests - javascript

I'm new to Javascript and I'm trying to learn express and create an application that will allow users to create new recipes, browse existing recipes, and view recipes.
I've got my server running by typing recipeserver.js in the cmd bar and then typing localhost:3000 in my address bar on google chrome. So far it loads the index.html homepage and from there, I am able to click on a link titled "Create a Recipe" which leads me to the create.html page that looks like this:
create.html page
Initially, there will be only three recipes on the server, which are included in the database object within the recipeserver.js code I've included below. The create.html page allows a user to enter recipe information. When the Save Recipe button is clicked, the addrecipe.js file is supposed to send the recipe data to the server using a POST request to the resource /recipes
Within the server code, all recipes will be stored in a single object called database. The keys of this object will be unique IDs and the values will be the recipes associated with those IDs. I'm stuck on a task where I'm supposed to add a route within the server code to handle POST requests to the /recipes resource. The handler for this route should:
Extract the recipe object included in the POST request body
Generate a unique ID for the new recipe (Etc. a basic integer that increases every time a recipe is added.)
Add a new entry into the recipes object with the key being the unique ID and the value being the recipe object.
When testing my code by adding a few recipes to my server, I should be able to just log the contents of the recipes object to see that it is storing the correct data, like in the picture below (this picture isn't mine):
load recipe in cmd
So as shown in the first picture of my screen, I filled in the contents of the recipe I want to add in create.html. When I click on the "Save Recipe" button however, instead of loading the contents of the recipe into my cmd window, I get the error:
TypeError: C:\Downloads\recipeApplication\views\recipes.pug:8
6| div#main
7| h1 List of Recipes:
> 8| each recipe in recipes
9| a(href="/recipes/" + recipe.id) #{recipe.name}
10| br
11|
Cannot read property 'length' of undefined
I'm a little stumped on how to a route within the server code to handle POST requests to the /recipes resource. I made a function called loadRecipes() that I'm trying to do all this in. I attempted to create a new id and increment it by 1 like the task suggests. I'm having trouble extracting the recipe object included in the POST request body. I attempted this and ended up commenting it out as it created the same error. I'm just trying to get the Save Recipe button to work so that the recipe that is added prints its contents in the cmd bar like in the 2nd picture, but I'm really lost and overwhelmed with the amount of information that comes up when I try to search for a solution and would appreciate some help in getting this to work.
Here's all my code incase anyone wants to run it but I believe my problem just lies in the recipeserver.js file. When the Save Recipe button is clicked, the addrecipe.js file sends the recipe data to the server using a POST request to the resource /recipes.
recipeserver.js:
const express = require('express');
const fs = require("fs");
const shortId = require("short-id");
const session = require('express-session');
const app = express();
const pug = require("pug");
const port = 3000;
let database = {
"0":{
"ingredients":
[
{"name":"Crab","unit":"Tsp","amount":3},
{"name":"Peas","unit":"Cup","amount":12},
{"name":"Basil","unit":"Tbsp","amount":10},
{"name":"Cumin","unit":"Liter","amount":3},
{"name":"Salt","unit":"Tbsp","amount":1}
],
"name":"Boiled Crab with Peas",
"preptime":"13",
"cooktime":"78",
"description":"A boring recipe using Crab and Peas",
"id":"0"
},
"1":{
"ingredients":
[
{"name":"Peanuts","unit":"Liter","amount":10},
{"name":"Artichoke","unit":"Tsp","amount":3},
{"name":"Basil","unit":"Cup","amount":11},
{"name":"Sage","unit":"Grams","amount":13},
{"name":"Pepper","unit":"Cup","amount":1}
],
"name":"Boiled Peanuts with Artichoke",
"preptime":"73",
"cooktime":"74",
"description":"A exciting recipe using Peanuts and Artichoke",
"id":"1"
},
"2":{
"ingredients":
[
{"name":"Lobster","unit":"Tsp","amount":14},
{"name":"Brussel Sprouts","unit":"Liter","amount":14},
{"name":"Sage","unit":"Tbsp","amount":3},
{"name":"Thyme","unit":"Tbsp","amount":12},
{"name":"Pepper","unit":"Tsp","amount":10},
{"name":"Cumin","unit":"Tbsp","amount":11}
],
"name":"Spicy Lobster with Brussel Sprouts",
"preptime":"86",
"cooktime":"19",
"description":"A tasty recipe using Lobster and Brussel Sprouts",
"id":"2"
}
}
let recipes = {};
for (let recipe in database) {
recipes[recipe.id] = recipe;
};
app.set("view engine", "pug");
app.use(express.static("public"));
app.use(express.json());
app.use(express.urlencoded({extended: true}));
app.get("/addrecipe.js", getAddRecipeJS);
app.get("/recipes", loadRecipes);
app.get("/recipe", loadRecipe);
app.route("/recipes", loadRecipes);
app.post("/recipes", loadRecipes);
let id = 1;
function loadRecipes(request, response, next){
response.status(200).render("recipes.pug", {"session": request.session});
/*
console.log("Request received!", request.body);
const newId = shortId.generate();
recipes[newId] = {
id: newId,
type: "recipe",
...request.body,
};
response.sendStatus(201);
*/
id++;
}
function loadRecipe(req, res, next){
res.status(200).render("recipe.pug", {"session": req.session});
}
function getAddRecipeJS(req, res, next){
fs.readFile("addrecipe.js", function(err, data){
if(err){
res.statusCode = 500;
res.end("Error reading file.");
return;
}
res.status(200).send(data);
return;
});
}
app.listen(port);
console.log(`Server listening at http://localhost:${port}`);
index.html:
<html>
<head><title>Recipe App Home Page</title></head>
<body>
<h1>Welcome to the Recipe App</h1>
<br>
Create a Recipe<br>
Browse Recipes<br>
</body>
</html>
create.html:
<html>
<head><title>Create a Recipe</title></head>
<body>
<script src="/js/addrecipe.js"></script>
<button type="button" onclick="genRandom()">Generate Random Recipe Data</button>
<button type="button" onclick="submit()">Save Recipe</button>
<br><br>
Recipe Name: <input type="textbox" id="recipename" size="50"><br>
Prep Time: <input type="textbox" id="preptime" size="50"><br>
Cook Time: <input type="textbox" id="cooktime" size="50"><br>
Description: <textarea rows="5" cols="50" id="description"></textarea><br><br>
Add ingredients:<br>
Unit: <select id="unit">
<option value="Tsp">Teaspoon</option>
<option value="Tbsp">Tbsp</option>
<option value="Cup">Cup</option>
<option value="Liter">Liter</option>
<option value="Gram">Gram</option>
</select><br>
Amount: <input type="textbox" id="amount"><br>
Ingredient: <input type="textbox" id="ingredient"><br>
<button type="button" id="add" onclick="addIngredient()">Add Ingredient</button>
<br><br>
<div id="ingredients">
</div><br>
<button type="button" id="submit" onclick="submit()">Save Recipe</button>
</body>
</html>
addrecipe.js:
let descriptors = ["Sweet", "Spicy", "BBQ", "Braised", "Deconstructed", "Broiled", "Boiled", "Flambeed", "Raw", "Smoked", "Butterflied", "Cured", "Grilled", "Poached"];
let proteins = ["Chicken", "Beef", "Lobster", "Shrimp", "Crab", "Turkey", "Duck", "Tofu", "Chickpeas", "Lentils", "Peanuts", "Kangaroo", "Human", "Goose", "Fish", "Pork", "Eggs", "Deer"];
let accompany = ["Broccoli", "Carrots", "Peas", "Potato", "Kale", "Banana", "Artichoke", "Asparagus", "Beans", "Broccoli", "Brussel Sprouts", "Celery", "Melon", "Mushrooms", "Pumpkin"];
let spices = ["Salt", "Pepper", "Basil", "Thyme", "Sage", "Cumin"];
let mealDescriptors = ["tasty", "mediocre", "very good", "boring", "exciting", "delicious", "easy", "ridiculously complex"];
let units = ["Tbsp", "Tsp", "Cup", "Liter", "Grams"]
let recipe = {ingredients: []};
function addIngredient(){
let name = document.getElementById("ingredient").value;
let amount = document.getElementById("amount").value;
let unit = document.getElementById("unit").value;
let ingredient = {name, amount, unit};
recipe.ingredients.push(ingredient);
updateIngredients();
}
function updateIngredients(){
let innerHTML = "";
recipe.ingredients.forEach(ingredient => {
innerHTML += ingredient.amount + " " + ingredient.unit + " " + ingredient.name + "<br>";
});
document.getElementById("ingredients").innerHTML = innerHTML;
}
function submit(){
recipe.name = document.getElementById("recipename").value;
recipe.preptime = document.getElementById("preptime").value;
recipe.cooktime = document.getElementById("cooktime").value;
recipe.description = document.getElementById("description").value;
let req = new XMLHttpRequest();
req.onreadystatechange = function() {
if(this.readyState==4 && this.status==200){
alert("recipe saved");
}
}
//Send a POST request to the server containing the recipe data
req.open("POST", `/recipes`);
req.setRequestHeader("Content-Type", "application/json");
req.send(JSON.stringify(recipe));
}
recipes.pug:
html
head
title Recipes
body
a(href="/create.html") add a recipe
div#main
h1 List of Recipes:
each recipe in recipes
a(href="/recipes/" + recipe.id) #{recipe.name}
br
recipe.pug:
html
head
title #{recipe.name}
body
div#main
h1 #{recipe.name}
br

First of all, thanks for putting in effort in explaining your issue in detail. One suggestions, you can share the repo instead of snippets of code (since this is quite long, and structure of folder do affects how we can get it up running).
Nonetheless, the error you're getting is due to recipes in recipes.pug is actually undefined.
index.js
function loadRecipes(request, response, next) {
response
.status(200)
// Here, you only pass `session` object to the template engine
// So template engine does not know about `recipes`
// So `recipes` is undefined, and you can't loop it
.render('recipes.pug', { session: request.session});
id++;
}
recipes.pug
html
head
title Recipes
body
a(href="/create.html") add a recipe
div#main
h1 List of Recipes:
// You're having issue here, since `recipes` is not passed to the template
// engine, it will throw an error
each recipe in recipes
a(href="/recipes/" + recipe.id) #{recipe.name}
br
Update your index.js with this
function loadRecipes(request, response, next) {
response
.status(200)
.render('recipes.pug', { session: request.session, recipes: database });
id++;
}
Now, you should be able to view the /recipes page and continue to work on the project.
I note there are quite number of bug in your code.
app.get('/addrecipe.js', getAddRecipeJS);
app.get('/recipes', loadRecipes);
app.get('/recipe', loadRecipe);
app.route('/recipes', loadRecipes);
app.post('/recipes', loadRecipes);
Based on this list of route, you shouldn't be using the same function to handle POST and GET request for /recipes.
GET can be used to retrieve the list of recipes
POST should be used to handle the data submitted, and save it to the database variable inside your index.js
I will give you a simple way of doing this (You should really explore yourself too)
app.post('/recipes', saveRecipes);
function saveRecipes(req, res, next) {
// Data submitted from your page is available in `req.body`
console.log(req.body);
// I'm trying to get a new `key` for the database
// This is because you're using number as `key` for each recipe
// Can skip this and use some random uuid as well
const dbLength = Object.keys(database).length;
// Add this to the database variable, and you're DONE!
database.dbLength = req.body;
res.send('ok');
}

Related

How do i correctly setup a "bucket" with a database I'm using an array to be called on in the blog page using ejs and javascript.?

I'm making a blog with ejs and in the server.js file I'm trying to call a database in my blog file, currently I'm just using a "hard coded" array in place before I make the database. I'm getting the error
TypeError: post.push is not a function. I tried using forEach and using the array as a variable it didn't work.
//route for blog page
app.get("/blog", function (req, res) {
app.get("blog")
const allPosts = [
{
title:"test",
content:"test test test"
},
{
title: "test test",
content: "test",
}
]
let post = allPosts[allPosts.length];
for (let post of allPosts){
post.push({
title:post.title,
content:post.content
})
}
res.render("blog");
});

Can anyone help me with node.js, database querying with a search box

So I am creating a web app for a calorie counter appl, the page im stuck on currently is a search food page, so the user types in the food in the search bar, if its in the database ive created it will show the food and all its nutrition,
Now this all works fine, however if the user types in a food which is not in the database or which is spelt incorrectly, it is supposed to be showing a message on screen stating so.
This is my main.js file
app.get("/search-result", function (req, res) {
//searching in the database
let word = [`%${req.query.name}%`];
let sqlquery = `SELECT * FROM food WHERE name LIKE '%${req.query.name}%'`;
db.query(sqlquery, (err, result) => {
if (err) {
return console.error('There is no food with that name' + req.query.name);
}else{
res.render('ListFood.html', {availableFood: result});
}
});
});
This is my index.js file
const express = require ("express");
const bodyParser = require ("body-parser");
const app = express();
const mysql = require("mysql");
const port = 8089;
app.use(bodyParser.urlencoded({ extended: true }));
const db = mysql.createConnection ({
host: "localhost",
user: "root",
password: "root",
database: "foodList" });
// connect to database
db.connect((err) => {
if (err) {
throw err;
}
console.log("Connected to database");
});
global.db = db;
require("./routes/main")(app);
app.set("views",__dirname + "/views");
app.set("view engine", "ejs");
app.engine("html", require("ejs").renderFile);
app.listen(port, () => console.log(`Example app listening on port ${port}!`));
This is my search food.html view file
<!doctype html>
<html>
<head>
<title>Search</title>
</head>
<body>
<h1> Food Search page </h1>
<p>In the box below please type in the name of the food you would like to search for in our database. If the food is in the database it will show you the nutritonal values, if it is not in our database and you would like to add it in, please visit the Add Food page.</p>
<form action="/topic7/mid-term/search-result/" method="GET">
<input id="search-box" type="text" name="name" value="Food Name">
<input type="submit" value="Submit" >
</form>
<br>
<strong>HOME</strong>
<br>
</body>
</html>
And finally this is my list food.html, this is the page it shows when the food is correct, but seems to get stuck reading the title and header even when the food is not in the database
<!doctype html>
<html>
<head>
<title>List webpage!</title>
</head>
<body>
<h1> Food List </h1>
<h3>You can see names and nutritional values of different food here:</h3>
<ul>
<% availableFood.forEach(function(food){ %>
<li><%= food.name %>, Typical Value: <%= food.typicalvalues %>, Unit of typical value: <%= food.Unitofthetypicalvalue %>, calories: <%= food.calories %>, carbs: <%= food.carbs %>, fat: <%= food.fat %>, protein: <%= food.protein %>, salt: <%= food.salt %>, sugar: <%= food.sugar %></li>
<% }) %>
</ul>
</body>
</html>
Ive been looking at this for hours and just cant seem to figure out why.
I am very new to this so any help is greatly appreciated.
As far as I know, the query function only returns an error if there was an actual error querying the database and not if no element was found. Even if no element was found, the function will hand your callback a results object. I am unsure of the structure of that object though, but with a bit of console logging you should be able to find out where to find the number of elements returned from the query.
You have to look at zero length results to show proper not found error message.
(err, result) => {
if (err) {
console.error('Database error in query data');
res.render('500.html')
return
}
if (result.length === 0) {
//show not found error
console.error('There is no food with that name' + req.query.name);
res.render('ListFoodEmpty.html')
}else{
res.render('ListFood.html', {availableFood: result});
}
});
Some options to follow
In my example I used a 'ListFoodEmpty.html' as a parameter in render function. If you choose that way, you have to implement a default html template for handle not found results.
Or you can reuse your ListFood.html template and check zero-length array before running the forEach, and put a proper error message for not found results.
If you choose this way, you can left your route /search-result as is and change the ListFood.html template.
I too would like to point out that if you are not validating your strings before running a query against database, you are open to sql injection atacks. You must use prepared statements offered by database lib, and sanitize and validate input before running.

Node JS/Express Routing

I need a little guidance with routing in my Node/Express app. Initially, I create a new business from the Business model (works fine). After creating the business, I want a separate route which adds the current FX rates offered by that business (these fields will then be updated daily). My business model looks like this (simplified for purpose of example):
let businessSchema = new mongoose.Schema({
name: String,
category: String,
longDescription: String,
images: [ {url: String, public_id: String} ],
usdHkd: { type: String, default: "" },
hkdUsd: { type: String, default: "" },
rateCreatedAt: {
type:Date,
default:Date.now
},
});
When the business is first created, only the name, category, longDesc and images are populated, with default values for the FX rate fields. That works fine using these routes:
/* GET business new /business/new */
router.get("/new", isLoggedIn, asyncErrorHandler(businessNew));
/* POST business create /business */
router.post('/', isLoggedIn, upload.fields([{ name: 'images', maxCount: 10 }]), asyncErrorHandler(businessCreate));
I then set up separate routes/controllers like this for subsequently adding the FX rates, but I don't think these are correctly defined:
/* GET business index /business */
router.get('/:id/remittance/new', asyncErrorHandler(remittanceNew));
/* GET business index /business */
router.put('/:id/remittance', asyncErrorHandler(remittanceCreate));
//Remittances New
async remittanceNew (req, res, next) {
let business = await Business.findById(req.params.id);
res.render('remittanceViews/newRemittance', { business });
},
//Business Update
async remittanceCreate (req, res, next) {
let business = await Business.findByIdAndUpdate(req.params.id, req.body.business);
console.log(business);
//update the post with any new properties
business.usdHkd = req.body.business.usdHkd;
business.hkdUsd = req.body.business.hkdUsd;
business.rateCreatedAt = req.body.business.rateCreatedAt;
//save the updated post in the db
business.save();
//redirect to show page
res.redirect(`/business/${business.id}`);
},
The error message I get when I try to update is:
Cannot read property 'usdHkd' of undefined
Can anyone please advise where I'm going wrong here? Thanks
The error message indicates that usdHkd's parent variable in undefined. Most probably, this error is coming from business.usdHkd in business.usdHkd = req.body.business.usdHkd; (you can confirm it by adding more console.log() lines around this line and checking the outputs).
If business.usdHkd = req.body.business.usdHkd; is giving error, that means, business is undefined. However, you don't need this line as business is already updated by findByIdAndUpdate.
READ: Model.findByIdAndUpdate() and Promises in Mongoose
//Business Update
async remittanceCreate (req, res, next) {
let business = await Business.findByIdAndUpdate(req.params.id, req.body.business);
console.log(business);
// Below code is not required since findByIdAndUpdate() will update your model
/*
//update the post with any new properties
business.usdHkd = req.body.business.usdHkd;
business.hkdUsd = req.body.business.hkdUsd;
business.rateCreatedAt = req.body.business.rateCreatedAt;
//save the updated post in the db
business.save();
*/
//redirect to show page
res.redirect(`/business/${business.id}`);
},
UPDATE
You told that business is defined, but it's not getting updated. The reason is findOneAndUpdate() requires new option to be set as true else findOneAndUpdate() returns the old object (before updating it -- in a sense). So, please change the first line of remittanceCreate() to:
let business = await Business.findByIdAndUpdate(req.params.id, req.body.business, {new: true});

Create pdf from HTML elements

What I want to do, is have a user dynamically create an image, like a nametag and then I want to save the image to the server as a pdf, then send the pdf via emil, to myself or someone else.
So far, I am able to dynamically create the nametag, and I am able to send an email when a button is pressed. Now what I can't seem to find is how to save the element as a pdf.
My code:
The endpoint that handles sending the email
let cors = require('cors');
let express = require('express');
let app = express();
app.use(cors());
let nodemailer = require('nodemailer');
/**
*
* Function to hopefully send an email :)
*/
app.post("/sendMail", function (req, res) {
console.log(req);
let transporter = nodemailer.createTransport({
service: 'gmail',
auth: {
user: 'user#gmail.com',
pass: 'Password'
}
});
let mailOptions = {
from: 'user#gmail.com',
to: 'recipient#alphagraphics.com',
subject: 'Test',
text: 'It works!'
};
transporter.sendMail(mailOptions, function(error, info) {
if (error) {
console.log(error);
} else {
console.log('Email sent: ' + info.response);
}
});
});
app.listen(8080);
The javascript that handles the button click to send the email
$('#some-long-stupid-unique-name').click(function(){
$.ajax({
type: 'POST',
url: 'http://192.168.1.23:8080/sendMail'
});
});
The html before editing
<div>
<div id="name"></div>
<div id="title></div>
</div>
Now the user will have some text boxees they cna type into and when they click "Update" whatever they typed into the text boxes (respectivly named Name and Title) the html will look like the following
<div>
<div id="name">My Name Here></div>
<div id="title">My Title Here</div>
</div>
How can I turn this element into a pdf and save it to my server, so I can then send it over from my mailing client?
Edit: I have seen other posts on how to "Save as pdf" but it seemed to me that they all save to the clients machine, but for me and the clients, it doesn't matter so much if they can save it on their machine, it is more important to save it to the server
Edit: Note that the format (pdf) doesn't matter so much I just thought it would be the easiest and most versatile?
If you would only save it as png, I would just say you to create a foreignObject inside an svg and render it on canvas, but since you want to convert that to pdf, I will do something that I rarely like doing. Try jsPDF, it should come in handy:
https://parall.ax/products/jspdf

Javascript Mongoose Database 'Doubling' (REST API - Weird)

I'm new to Javascript and I'm having a recurring error with a REST API. It's a strange error (for me at least), so strange that I don't know what to call it. I'm calling it "Doubling", but it probably has a proper name, I just don't know what it is.
Anyway, the situation is this. I'm creating a REST API about cars. I'm using Javascript and the following node modules:
1) Express
2) Body-Parser
3) Mongoose
4) MongoDB
5) Mongod
The DB is very simple. It literally just lists the names of cars. Here's the code for it:
var express = require('express');
var bodyParser = require('body-parser');
var theAutos = require('./cardata');
var mongoose = require('mongoose');
var app = express();
app.use(express.static('public'));
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
mongoose.Promise = global.Promise;
var promise = mongoose.connect('mongodb://localhost/car_test_project', {
useMongoClient: true,
});
promise.then(function(db){
console.log('DATABASE NOW CONNECTED!!');
}).catch(function(err){
console.log('CONNECTION ERROR', err);
});
//*****SCHEMA*****
var Schema = mongoose.Schema;
var carTestSchema = new Schema({
name: String,
});
var Car = mongoose.model('Car', carTestSchema);
//*****END SCHEMA*****
//*****CAR DATA 'FOR EACH' FUNCTION*****
theAutos.forEach(function(theAutos){
var newAutomobile = new Car(theAutos);
newAutomobile.save(function (err) {
if (err) {
return (err);
}
});
});
//*****END 'FOR EACH' FUNCTION*****
//******THE 'GET' CODE*****
app.get('/carurl', function(req, res){
console.log(3);
Car.find({}).exec(function(err, car){
console.log(2);
if(err) {
return res.status(500).send(err);
}
return res.json(car);
});
});
//******END THE 'GET' CODE*****
//*****POST COMMAND CODE*****
app.post('/carurl', function(req, res){
var addAnAuto = new Car(req.body);
addAnAuto.save(function(err, car) {
if(err) {
return res.status(500).send(err);
}
return res.status(201).json(car);
});
});
//*****END POST COMMAND CODE*****
app.listen(8000, function(){
console.log('I be listening!');
});
At the beginning, the DB only has one entry; Ferrari. I've put this in a separate file called cardata.js and then I 'require' that file in the 3rd line of the above code (that's what the var theAutos = require('./cardata'); refers to. Here's the code for that file:
module.exports = [
{name: "Ferrari"}
]
As you can see, very simple database with only one entry. Now, here's where things get WEIRD!
I go to Postman and make a GET request. Postman comes back with Ferrari. So far so good. Then I go to make a POST request. I ask for a second car to be added to the database, in this case a Bugatti. I make a second GET request and I see:
{
"_id": "123etc...",
"name": "Ferrari",
"__v": 0
}
{
"_id": "xyzetc...",
"name": "Bugatti",
"__v": 0
}
So it's adding Bugatti to the database. That's great, right? It's doing what it's supposed to.
Wrong!
See, I need to make sure the addition is permanent, right? So I go to my terminal and restart the database by typing node index.js. I then go back to Postman and make yet another GET request. I'm expecting to see just Ferrari and Bugatti, right? However what I actually see, is:
{
"_id": "123etc...",
"name": "Ferrari",
"__v": 0
}
{
"_id": "xyzetc...",
"name": "Bugatti",
"__v": 0
}
{
"_id": "123etc...",
"name": "Ferrari",
"__v": 0
}
WTF?!? Where did that extra Ferrari come from? I certainly didn't want it there. It's like the DB is loading the DB with my POST request and then loading the original DB (which just had Ferrari in it) on top! Hence "Doubling"
Now, you might be thinking, "Shank, you fool! Just use a drop command like Car.collection.drop(); to refresh the DB when you reload it!"
Trouble is, when I try that I lose my Bugatti!
What I need is to figure out a way to (a) Add my Bugatti and other cars to the database and (b) do so in such a way that when I restart the database it doesn't "Double" and add another Ferrari in there.
It's no exaggeration to say I'm absolutely DESPERATE for help at this point. I've been grappling with this for days and I've read countless online tutorials and I've not come up with ANYTHING that can help me.
Any advice you could give would be massively appreciated.
Cheers,
Shank.

Categories