Hi there! So the SQL commands all happen in src/sqlite.js. To update the text on the page, edit src/pages/index.hbs for the main form and src/pages/admin.hbs for the admin page that shows the data so far.
Now, if you’re editing the form questions, you’ll need to make sure servers.js is updated to receive the same params the form is sending so it can then do the queries you updated in src/sqlite.js. I hope this steers you in the right direction, I understand it’s a lot!
Note : Honestly, I already understood what you are saying there is no relevant information in your post. Your explanation is not really helpful to the community. I think a very simple tutorial here can help many Glitch users. Moreover I found the old version (with the dreams to be added) more relevant and better built, but it does not save the data.
Here’s what I produced (just belox) and what I was able to do, my edits didn’t fix the problem, but I’m sharing it so you can tell me what’s wrong and help the community.
MY WORKS :
Step 1 : I’ve started by edit the src/pages/index.hbs :
Step 2 : Then I got to src/pages/admin.hbs in order to delete the column 1 related to past language selected, and adding instead a column to show the text submitted in my new field :
Step 4 : Edit sqlite.js (please note I’ve added my code from the line 28)
Here is the code I’ve added :
//We add a new table for text input
try {
await db.run(
"CREATE TABLE TextInput (id INTEGER PRIMARY KEY AUTOINCREMENT, text TEXT, time TIMESTAMP)"
);
} catch (dbError) {
console.error(dbError);
}
// Add method to process the text input
processText: async text => {
try {
// Insert new TextInput table entry indicating the user input and timestamp
await db.run("INSERT INTO TextInput (text, time) VALUES (?, ?)", [text, new Date().toISOString()]);
return await db.all("SELECT * from TextInput");
} catch (dbError) {
console.error(dbError);
}
},
// Add method to get the logs for text input
getTextLogs: async () => {
try {
return await db.all("SELECT * from TextInput");
} catch (dbError) {
console.error(dbError);
}
},
“Note : Honestly, I already understood what you are saying there is no relevant information in your post. Your explanation is not really helpful to the community.” Point taken I guess, lol, also I’m not a “Sir”.
If you look in the logs of your project, you will see that there’s a syntax error. You’re missing a bracket or something. You can compare your current code to my cleaned up version in a remix of your project (Glitch :・゚✧). Fixing that will lead to logs on some errors you have with duplicate routes on server.js.
Hoping this puts you in the right direction, apologies in advance for not writing an entire tutorial on here - I’ll let the team know that this is something we should consider writing up.
Yes, because there are more errors in other parts of the code. If you click the “Logs” tab on the bottom of the editor it will tell you what’s happening, or at least where it’s happening.
You can only have one code .post() and .get() function for each route - this app has two routes, “/” for the front page/index and “/admin” for the admin page. You seem to have multiples of each on that page for each route, so you’d need to delete the entire code block of the ones you aren’t using. By code block, I mean everything from fastify.post(‘/’ to the closing }); part. As you delete, look to the logs to find out where it’s finding issues.
And if you accidentally delete too much, feel free to copy the code from my remix of the original state of your app when I first remixed it!