mysql-dal

1.0.4 • Public • Published

mysql-dal

About

a mysql-orm mini package

How use

First make a mysql-config.js file

// mysql config file like this:
module.exports = {
    connectionLimit: 10,
    host: '127.0.0.1',
    user: 'root',
    password: 'your password',
    port: 3306,
    database: 'db-name'
}

And then new class

let SqlDal=require('mysql-dal');
let config=require('./mysql-config');

let sqlDal=new SqlDal(config,'tb_user');

sqlDal.findAll().then(console.log,console.log);

API

query(sqlStr, params):Promise<Array>

insert(entity):Promise<Array>

truncate():Promise<Array>

remove(whereStr):Promise<Array>

removeById(id):Promise<Array>

update(entity, whereStr):Promise<Array>

updateByParams(entity, where):Promise<Array>

updateById(entity, id):Promise<Array>

findAll(columns,orderStr):Promise<Array>

findById(id):Promise<Array>

findOne(query):Promise<Array>

findWithQuery(query):Promise<Array>

findTop(columns, count, whereStr):Promise<Array>

findCount(fromStr, whereStr):Promise<Array>

find(columns, whereStr, sortStr, count):Promise<Array>

findByPage(fieldStr, fromStr, whereStr, sortStr, pageIndex, pageSize):Promise<Array>

getTableNames(tableName):Promise<Array>

findColumnName(tableName):Promise<Array>

findMaxId(tableName):Promise<Array>

/mysql-dal/

    Package Sidebar

    Install

    npm i mysql-dal

    Weekly Downloads

    4

    Version

    1.0.4

    License

    MIT

    Unpacked Size

    8.21 kB

    Total Files

    4

    Last publish

    Collaborators

    • lanmeng2022