₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,331,008 members, 8,448,217 topics. Date: Monday, 20 July 2026 at 01:16 AM

Toggle theme

My First Day With Node Js (I Made My Own Database System) - Programming - Nairaland

Nairaland ForumScience/TechnologyProgrammingMy First Day With Node Js (I Made My Own Database System) (1320 Views)

1 Reply (Go Down)

My First Day With Node Js (I Made My Own Database System) by Fourpockets(op):
I decided to try out node after getting bored from frontend and decided to see how backend works fully. So I went through w3schools and node is docs then I started playing with the server module to send APIs.
I then had a thought, when I end my server, all the JSON objects I send to my server to store in an array wouldn't save. I also couldn't find a built in module in node for local storage so I came up with my own custom database smiley .
It's not a database they you can use o, except you copy the code, it's just something I wanted to try to see if it's possible grin

It works like this:
The database is a JSON file with an empty array at first, I then read the file with the built-in file system module, parse the JSON file, when the post request comes in, I'll push it into the new js array, then I'll stringify it and write(overwrite) the existing empty array using the write file method from the file system module.

Here is the link to the code, I actually forgot to comment in the files undecided
Re: My First Day With Node Js (I Made My Own Database System) by chukwuebuka65(m): 12:23pm On Sep 28, 2022
Nice. JSON.parse() do throw errors and will crash a server if the string passed cannot be parsed to an object .Try to catch it.
Re: My First Day With Node Js (I Made My Own Database System) by Fourpockets(op): 12:27pm On Sep 28, 2022
chukwuebuka65:
Nice. JSON.parse() do throw errors if the string passed cannot be parsed to an object and crash your server. Try to catch it.
No errors there, I've tested it. I linked the GitHub file, you can check yourself
Re: My First Day With Node Js (I Made My Own Database System) by chukwuebuka65(m): 12:31pm On Sep 28, 2022
Fourpockets:
No errors there, I've tested it. I linked the GitHub file, you can check yourself
You don’t understand what I mean. You should rap it with a try catch statement as a precaution incase accidentally a string that can not be parsed is passed to it. I don’t mean it throws an error now.
Re: My First Day With Node Js (I Made My Own Database System) by Nobody: 12:46pm On Sep 28, 2022
Only u Sabi wetin u the build.

grin

I saw ur code... Why didn't u use express to make your life easier....


The way u were commenting on one thread like that I thought u even had 2-3 years experience coding.... Who would have imagined this shiit.
Re: My First Day With Node Js (I Made My Own Database System) by chukwuebuka65(m): 1:01pm On Sep 28, 2022
GREATIGBOMAN:
Only u Sabi wetin u the build.

grin

I saw ur code... Why didn't u use express to make your life easier....


The way u were commenting on one thread like that I thought u even had 2-3 years experience coding.... Who would have imagined this shiit.
His first day with nodejs. Guy nawa for you oo. I no just understand your way.
Re: My First Day With Node Js (I Made My Own Database System) by Fourpockets(op): 1:29pm On Sep 28, 2022
GREATIGBOMAN:
Only u Sabi wetin u the build.

grin

I saw ur code... Why didn't u use express to make your life easier....


The way u were commenting on one thread like that I thought u even had 2-3 years experience coding.... Who would have imagined this shiit.
It was my first time using node is sir. I wanted to learn how it works, hence I didn't use any framework, tho from now on I'll be using express for creating servers cos from what I've seen, it's 100 times better than raw node
Re: My First Day With Node Js (I Made My Own Database System) by Fourpockets(op): 1:33pm On Sep 28, 2022
GREATIGBOMAN:
Only u Sabi wetin u the build.

grin

I saw ur code... Why didn't u use express to make your life easier....


The way u were commenting on one thread like that I thought u even had 2-3 years experience coding.... Who would have imagined this shiit.
... Also, you said you don't understand what I did, but also called it shit 2 paragraphs later undecided
Re: My First Day With Node Js (I Made My Own Database System) by Nobody: 1:35pm On Sep 28, 2022
chukwuebuka65:
His first day with nodejs. Guy nawa for you oo. I no just understand your way.
Hmm... Don't stress yourself
Re: My First Day With Node Js (I Made My Own Database System) by Nobody: 1:36pm On Sep 28, 2022
Fourpockets:
... Also, you said you don't understand what I did, but also called it shit 2 paragraphs later undecided
Yes bro
Re: My First Day With Node Js (I Made My Own Database System) by jansonn(m): 1:37pm On Sep 28, 2022
Hi bro
I'm working on a project that has some real life application that I would love to go life. I would like to contact you for the backend part. Non-pay actually
Re: My First Day With Node Js (I Made My Own Database System) by Fourpockets(op): 5:05pm On Sep 28, 2022
chukwuebuka65:
His first day with nodejs. Guy nawa for you oo. I no just understand your way.
I wish I understood that guy I swear
Re: My First Day With Node Js (I Made My Own Database System) by truthCoder: 6:13pm On Sep 28, 2022
Use Express

Get a Database connected

Serve via endpoints

Secure the bag
Re: My First Day With Node Js (I Made My Own Database System) by Fourpockets(op): 9:26pm On Sep 28, 2022
truthCoder:
Use Express

Get a Database connected

Serve via endpoints

Secure the bag
I know, next time I'm using express... I just wanted to know how node is works, that's why I didn't use any framework there
Re: My First Day With Node Js (I Made My Own Database System) by Fourpockets(op): 7:38pm On Sep 29, 2022
jansonn:
Hi bro
I'm working on a project that has some real life application that I would love to go life. I would like to contact you for the backend part. Non-pay actually
Just saw this.
Im still learning backend so I'm not the person for you
Re: My First Day With Node Js (I Made My Own Database System) by Qtrpst4: 1:44am On Sep 30, 2022
What is it about?
jansonn:
Hi bro
I'm working on a project that has some real life application that I would love to go life. I would like to contact you for the backend part. Non-pay actually
Re: My First Day With Node Js (I Made My Own Database System) by jansonn(m): 6:47am On Sep 30, 2022
Qtrpst4:
What is it about?
it's a medical recording keeping system for patients. I could contact you you if you want details. However, I really don't have money to pay. Maybe we could just be co-founders cheesy cheesy
Re: My First Day With Node Js (I Made My Own Database System) by Qtrpst4: 12:45pm On Sep 30, 2022
OK, I will want to know about it. Though am not to strong with back end but am trying my hands on it
Let's talk
jansonn:
it's a medical recording keeping system for patients. I could contact you you if you want details. However, I really don't have money to pay. Maybe we could just be co-founders cheesy cheesy
Re: My First Day With Node Js (I Made My Own Database System) by jansonn(m): 3:08pm On Oct 01, 2022
Qtrpst4:
OK, I will want to know about it. Though am not to strong with back end but am trying my hands on it
Let's talk
I've sent you a mail
Re: My First Day With Node Js (I Made My Own Database System) by Qtrpst4: 3:49pm On Oct 01, 2022
I didn't receive it
jansonn:
I've sent you a mail
1 Reply

Backend Dev With Node Js And Express Needed.remote WorkHelp With Node.js App Deployment To Heroku (Solved!!!)Deep Knowledge Of Distributed Database System And Mapreduce234

Virus Threathens My JobThe Part To Becoming A Good Programmer, A Guide To Infiltrating The MarketAnother Challenge For Java Gurus