Base
The best place to start, of course.
Installing better-mysql
If you have NodeJS (and NPM, this will be in the installation), run this command at your projectfolder:
Logging in to the account
Next, we have to login to the account of the mysql databases. Do that with the host, username and password.
Make a file in your projectfolder with the extention .js, like bot.js, server.js or index.js.
Queues
By default, the queues are on. There isn't a option to fully disable queues, but you can set the interval time very low. You can set the queue to very low with the option queue
in the client constructor.
If you want to chance the default interval, what is 500 ms
, you can do that with the option queueInterval
. Here are some examples.
See the databases
To make/connect to a table, we have to use a database. But it can come in handy if you want to see the databases before we connect to a database. That can be done by those two lines of code:
As you can see, there are two examples: The main example
and the compact
example. The two examples uses the same code and calling the same function.
But the main example is storing the databases in a variable and then logging the variable, and the compact example is logging the return of the function.
Both examples are using async and await, becouse we have to get a connection to the database. But, if you don't want to or don't know how to use async, you can also use .then! Here is a example of using .then.
Selecting a database
Now, let's select a database!
Making a database
There are some issues with making a database. In the next version those issues are fixed. Sorry for this!
Loading a database
If you already have a database, you can load it, so you can make/use tables! The database we are going to load is called example
. There are two ways, with await and with .then.
Renaming a database
If you want to rename a database, you can do that too! Just use the client.renameDatabase
function! Here is an example. The database called exxample
will be renamed to example
.
Deleting a database
You can delete a database with the client.deleteDatabase
function! Here is an example where the database example
will be deleted.
Last updated