Save two IDs in a database

Hello!

I want to make an anonymous ticketing system (which would go through DM <-> a server channel). To reply, users need to tell their ticket ID to the bot. If the ticket ID belongs to the user’s ID, it will send a reply.

How can I store two IDs per row in a database? I can’t figure out where to start and what the best way to do this is.

Thanks! :smile:

Hi there @QkeleQ10!
Could you let us know what type of database you are using? sqlite? MongoDB? This will help us answer you question :slight_smile:

Eddie

I am not currently using any database, as I don’t know what I should choose and how I could use it.

1 Like

Would recommend MongoDB Atlas using Mongoose! Best one I have found! Lots of tutorials on how to use it with discord.js :slight_smile:

2 Likes

Isn’t there an easier way? Sorry but I’m new to coding in file systems and stuff (I know JavaScript but in a different environment, which has built-in, easy to access databases)

Not really, that I know of. However, once you get used to it, MongoDB is easy. You just need the connection string from Atlas and stick that in to make a connection, make a schema and then insert. Loads of tutorials and stuff :slight_smile:

You could try using json, but you’ll live your whole life having people telling you to use a database :joy:

1 Like

Lol, well I kinda just want one simple thing and not too many “easy” APIs. This is just too much of a hassle for one snippet of one tiny bot command.

I am now trying to use http requests and grab data from my own database.

I’d recommend quick.db/keyv for starters. It’s fully JSON orientated, quick and doesn’t require a server since it uses SQLite, which is local.

Using MongoDB/SQL raw as a starter is difficult since you are required to worry about tables/collections, columns, datatypes etc.

Like SpeedCraftah mentioned, SQLite is a great choice to start out with. I myself use Enmap for my smaller projects, which is another SQLite driver, and is very similar to quick.db, just with way more features like;

Ensure, which basically can be used to make sure a ID exists in the db and if it doesn’t it adds it.
It also has features designed for Arrays which last time I used quick.db, it didn’t have.
And many more which I haven’t needed to use yet.

In the end both of them work well as a small, starter databases.