Ask coding questions

← Back to all posts
How to save data in node.js?
Axel1672 (5)

How to save data in node.js?

(50 charsssssssssssssss)

Comments
hotnewtop
Coder100 (18109)

there's multiple ways to do it, the easiest is replit db
https://docs.replit.com/misc/database

ruiwenge2 (563)

you can use the replit database, like this:

const Database = require("@replit/database");
const db = new Database();

db.set("number", 2).then(() => console.log("saved"));

hope this helps!

ruiwenge2 (563)

you can set anything you want, like color could be blue.

Axel1672 (5)

@ruiwenge2 It don't works for me

if (message.content.toLowerCase() === Prefix + 'verify' && db.get("verify|" + message.author.id) === 1 && message.member.roles.cache.find(role => role.name != "Verified")) {
    message.channel.send("<@" + message.author.id + ">" + " You already have a pending verification");
  }
  else if (message.content.toLowerCase() === Prefix + 'verify' && db.get("verify|" + message.author.id !==1 || db.get("verify|" + message.author.id) === null) && message.member.roles.cache.find(role => role.name != "Verified")) {
    if (message.channel.type === "text") {
db.set("verify|" + message.author.id, 1).then(() => console.log("saved"));
ruiwenge2 (563)

@Axel1672 what was that code you just put?

ruiwenge2 (563)

@Axel1672 what part doesn't work?

Axel1672 (5)

@ruiwenge2 It does not work in the part that I get the data in the database

ruiwenge2 (563)

@Axel1672 you need to set the key and the value first, like this:

db.set("verify", true).then(() => console.log("saved"));