1.1.0 • Published 1 year ago

sqldb-orm v1.1.0

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

db-orm

About

a sql-orm mini package.

can use mysql or sqlite3 database.

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

//use mysql
let orm=require('sqldb-orm');
let config=require('./mysql-config');

async function main(){
    let sqlDal=await orm.getClass('mysql',config,'tb_user',true);
    let list=await sqlDal.findAll();
    console.log(list);
}
main();
//use sqlite3
let orm=require('sqldb-orm');
let config='./test.db3';
async function main(){
    let sqlDal=await orm.getClass('mysql',config,'tb_user',true);
    let list=await sqlDal.findAll();
    console.log(list);
}
main();

API

testConnect(dbFile):Promise<Array>

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>
1.1.0

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago