Thursday, 23 July 2020

Node Forum from Scratch?

Hey guys,at the moment im building my own webside and kinda got stuck while trying to make my forum work!I dont wanna use any finished Forum frameworks! I have 2 major questions that would make me understand how to create a forum.First one:At the moment i have an Array on my server with all the posts in it:class ForumPost { constructor(pTitle, pDescription, pUser, pDate) { this.date = pDate; this.user = pUser; this.title = pTitle; this.description = pDescription; } } let ForumPosts = new Array() let sql = "SELECT * FROM forum" conn.query(sql, (err,result)=>{ if(err) throw err; for(i = 0; i < result.length; ++i) { let user = result[i].user let date = result[i].date let title = result[i].title let description = result[i].description console.log("pushed objects into array!") ForumPosts.push(new ForumPost(title,description,user,date)) } }); With this i used a loop on pug to create html for every object in the array ForumPosts!I thought about this way, but would'nt my server use way to much ram if my forum actually has like millions of posts?. Because all of it would get saved on my server!So my second thought:I need to make sure that my server actually writes the html code and safes the html code so i dont have to have an array on my server with my whole database.​Are those atleast right ways of thinking to create a forum? Or are there ways that would make way more sense?.I really got stuck because im not sure how i should go forward on my forum! Would appreciate any help!If you have any questions, feel free to ask! Ill answer everyone!(Im pretty new to programming. I started 3 months ago to learn Javascript/node & HTML/CSS)

Submitted July 23, 2020 at 11:32AM by Cebrail_h

No comments:

Post a Comment