This package has been deprecated

Author message:

Package is no longer maintained. Moved to new package name slim-node-mysql

prohairesis
TypeScript icon, indicating that this package has built-in type declarations

1.2.5 • Public • Published

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

Package Sidebar

Install

npm i prohairesis

Weekly Downloads

4

Version

1.2.5

License

ISC

Unpacked Size

12.6 kB

Total Files

5

Last publish

Collaborators

  • jakecyr