How to add comment system like of replit or youtube using nodejs and replit DB?
I thought of using MongoDB but it is not possible on replit as I downloaded it on my PC. I cannot import and run it on replit.
ENOUGH! Mongo! your ded!!
How to make a comment system, like of replit's or youtube.
AND USING ONLY REPLIT DATABASE, NOT mongooseDB
What would it be a part of though? Would it be connected to specific pages, like with replit and youtube? How are users tracked? Who can see the comments? Please provide a Repl so that we can figure out these answers.
just to start off, just like a basic comment is going to include 1. a comment and 2. a username. I'd probably add like a comment id to that list too probably actually.
Repldb is pretty easy to use, you just use the
get functions, providing a key (and a value when appropriate).
You can see here I'm storing text, because, AFAIK, Repldb can only store text, but that should be fine as of course JSON objects are easily serialized using
JSON.stringify(obj) or whatever it is.
Again, if you want some suggestions that are more helpful to your situation, then please provide a Repl.
First off, getting the Repl_db package is easy as any module import, but with a slightly weirder module name:
Now that we have a the module, we make an actual database using the module as a class. (All of this stuff I'm talking about can found in the docs)
setting a value is really easy, but you can only store strings, and you need to always provide a key. For your purposes, I'd probably just use an ever-increasing number to signify it's order in the comments or something.
getting a value is just as easy
For your purposes though, I'd use the list function instead, which lists all of the currently stored keys, and then just get them all in a row.
I'm gonna leave the rest up to your already competent hands.