1.2.5 • Published 3 years ago

prohairesis v1.2.5

Weekly downloads
44
License
ISC
Repository
github
Last release
3 years ago

Prohairesis

MySQL database class to abstract pooling and prepared statements

Installation

const { Prohairesis } = require('prohairesis');

// create new database instance
const database = new Prohairesis(env.database);

Methods

query

database.query(`
    SELECT
        *
    FROM
        User
    WHERE
        id = @id
`, {
    id: 1,
});

// returns an array of rows found

getOne

database.getOne(`
    SELECT
        *
    FROM
        User
    WHERE
        id = @id
`, {
    id: 1,
});

// returns an object of row found or null if no rows returned

getValue

const username = database.getValue('username', `
    SELECT
        *
    FROM
        User
    WHERE
        id = @id
`, {
    id: 1,
});

// returns value from column specified

execute

const response = database.execute(`
    INSERT INTO User(
        username,
        password
    ) VALUES (
        @username,
        SHA2(@password, 256)
    )
`, {
    username: 'jake',
    password: 'passwordHere',
});

console.log(response); // { insertId: 1, affectedRows: 1, etc... }

exists

const userExists = database.exists(`
    SELECT *
    FROM User
    WHERE id = @id
`, {
    id: 1,
});

console.log(userExists); // true
1.2.5

3 years ago

1.2.4

3 years ago

1.2.3

3 years ago

1.2.2

3 years ago

1.2.1

3 years ago

1.2.0

4 years ago

1.1.9

4 years ago

1.1.8

4 years ago

1.1.7

4 years ago

1.1.6

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago