megasql.db - a Database for starters
Description: megasql.db is a database made by Ruben, it allows the user with a low/0 knowledge about databases to store values and add more interesting things in a database with an easy way!
Functions of megasql.db:
.fetch(userid, variable, valueIfNull(optional), newValue(optional))
- fetchs a variable and gets his value to a let, var, const
function.
.get(userid, variable)
- gets a variable value from given user id.
.add(userid, variable, value)
- adds a value to given variable name and user id.
.subtract(userid, variable, value)
- subtracts a value to given variable name and user id.
.cooldown(userid, command, time(ms))
- adds a cooldown to the command, you'll have to use a variable.
.sortData(variable)
- returns all the values of a variable sortered
.set(userid, variable, value)
- sets a new value for given variable name.
.condition(userid, variable, condition, number)
- used to make a condition with a variable value, itll return true or false.
.removeCooldown(userid, command)
- removes a cooldown from given command name and user id.
.addEvent(event, duration)
- adds an event where event is the event name and duration is the duration of the event in milliseconds.
.getEvent(event, parse(optional))
- gets an event with given event name. If you set parse to true, it'll return the time in hours, minutes, seconds... If it isn't setted, it'll return the milliseconds left of that event.
.map(userid, ["var1", "var2", ...], valueIfNull(optional))
- mainly used for load multiple variables from given user id and put them in an array, if valueIfNull is setted, variables with null values will be replaced with valueIfNull.
.setVars(userid, ["var1", "var2", ...], [0 , 50, ...])
- sets multiple variables to given values of chosen userid.
.addToVars(userid, ["var1", "var2", ...], [2 , 10, ...], valueIfNull(optional))
- add to multiple variables the given values of chosen userid.
.subtractToVars(userid, ["var1", "var2", ...], [5 , 13, ...], valueIfNull(optional))
- subtract to multiple variables the given values of chosen userid.
Examples using megasql.db
:
Imagine we want to add a cooldown for a command, here we go:
client
Or maybe we want to do a leaderboard:
client
What about a condition?
client
What about an event:
client //next command would be: client
Now, let's gonna get multiple variable values:
client
Isn't it easy? :D
Remember to use async
because megasql.db takes some milliseconds to load the values.
If you need more help contact us on our Discord Server.