5.0.4 • Published 2 years ago

mysqldriver v5.0.4

Weekly downloads
372
License
ISC
Repository
github
Last release
2 years ago

MySQLDriver

Sample usage

const MySQLDriver = require('mysqldriver');
const config = {
  host: '127.0.0.1',
  user: 'admin',
  password: 'password',
  database: 'mydatabase',
  port: 3306,
};
const DB = MySQLDriver.connect(config);
const users = await DB.getRecords('user', { name: 'John Doe' }); // Gets all records who have name John Doe

Setting up the test database

Execute the following statements

CREATE DATABASE mysqldriver_test;
CREATE USER 'testuser'@'%' IDENTIFIED WITH mysql_native_password BY 'P@ssw0rd';
GRANT ALL PRIVILEGES ON mysqldriver_test.* TO 'testuser'@'%';
FLUSH PRIVILEGES;

Create a configuration file dbconfig.js

const config = {
  host: '127.0.0.1',
  database: 'mysqldriver_test',
  password: 'P@ssw0rd',
  user: 'testuser',
};
module.exports = config;

Migrations

Create a new migration

DB_HOST=127.0.0.1 DB_DATABASE=mysqldriver_test DB_USERNAME=testuser DB_PASSWORD=P@ssw0rd mysqldriver create-migration --name createNewTable

Apply migrations

DB_HOST=127.0.0.1 DB_DATABASE=mysqldriver_test DB_USERNAME=testuser DB_PASSWORD=P@ssw0rd mysqldriver migrate --count 500

Rollback a migration

DB_HOST=127.0.0.1 DB_DATABASE=mysqldriver_test DB_USERNAME=testuser DB_PASSWORD=P@ssw0rd mysqldriver rollback --count 500

Migration options

DB_HOST= # The database host
DB_DATABASE= # The database to connect to
DB_USERNAME= #The database user's username
DB_PASSWORD= #The password for the database user
DB_PORT= #The port to connect to
DB_SSL_CA_CERTIFICATE # The base64 encoded string for the CA certificate
DB_REQUIRE_SSL= # Whether to enforce that the connection requires an ssl connection (1 or 0, defaults to 1 if cetificate is provided)
DB_SSL_ALLOW_SELF_SIGNED_CERT= # Whether self-signed certificates are allowed (1 or 0, defaults to 0)
5.0.4

2 years ago

5.0.3

2 years ago

5.0.2

2 years ago

5.0.1

2 years ago

4.4.1

3 years ago

5.0.0

3 years ago

4.4.0

3 years ago

4.3.11

4 years ago

4.3.10

4 years ago

4.3.9

4 years ago

4.3.8

4 years ago

4.3.7

4 years ago

4.3.6

4 years ago

4.3.5

4 years ago

3.0.23

4 years ago

4.3.4

4 years ago

4.3.3

4 years ago

4.3.2

4 years ago

4.3.1

4 years ago

4.3.0

4 years ago

4.2.0

4 years ago

4.1.6

4 years ago

4.1.4

4 years ago

4.1.3

4 years ago

4.1.5

4 years ago

4.1.2

4 years ago

4.1.1

4 years ago

4.1.0

4 years ago

4.0.1

4 years ago

4.0.2

4 years ago

3.0.20

5 years ago

3.0.19

5 years ago

3.0.18

5 years ago

3.0.16

5 years ago

3.0.17

5 years ago

3.0.15

5 years ago

3.0.13

5 years ago

3.0.14

5 years ago

3.0.12

5 years ago

3.0.11

5 years ago

3.0.10

6 years ago

3.0.9

6 years ago

3.0.8

6 years ago

3.0.7

6 years ago

3.0.6

6 years ago

3.0.5

6 years ago

3.0.4

6 years ago

3.0.3

6 years ago

3.0.2

6 years ago

3.0.1

6 years ago

3.0.0

6 years ago

2.0.12

6 years ago

2.0.11

6 years ago

2.0.10

6 years ago

2.0.9

6 years ago

2.0.8

6 years ago

2.0.7

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago