Skip to content
← Back to Community
How to save data in node.js?
Profile icon
Axel1672

How to save data in node.js?

(50 charsssssssssssssss)

Voters
Profile icon
Axel1672
Comments
hotnewtop
Profile icon
Coder100

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

Profile icon
ruiwenge2

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!

Profile icon
ruiwenge2

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

Profile icon
Axel1672

@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"));
Profile icon
ruiwenge2

@Axel1672 what was that code you just put?

Profile icon
ruiwenge2

@Axel1672 what part doesn't work?

Profile icon
Axel1672

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

Profile icon
ruiwenge2

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

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