Ask coding questions

← Back to all posts
How to add comment system like of replit or youtube using nodejs and replit DB?
PixiGem

Pls help!

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

Voters
PixiGem
Comments
hotnewtop
Highwayman

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 store and 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 obj.toString() or 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.

PixiGem

@Highwayman this is my goal -
there is an input(textarea), and a button to submit
the user types in the textarea and clicks submit.
The webpage adds a permanent text which was typed into the textarea
How can we do that on replit

Highwayman

Okay.

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.

@PixiGem

PixiGem

BRUH. how about the button. I cant understand :(
my body gave me this error -

npm error: no module named brain