jh-common-dataaccess 通用数据库操作
支持常见数据库操作,如 sqlserver、mysql、postgresql、
sqlite等,可实现通用查询和数据映射
暂时屏蔽对sqlite
的支持,使用率不高,下载速度慢
Installation
$ npm install jh-common-dataaccess
Quick Example
Please make sure that the following information exists in your databases.
database:ECommerce
、table:userinfo
Field | Type |
---|---|
id | string |
createby | string |
const DataAccess = ; const ds = type: 'mysql' host: '127.0.0.1' user: 'sa' password: '123456' port: '3506' database: 'ECommerce' multipleStatements: true useConnectionPooling: true; ds ;
Config
mysql
mssql
postgre
sqlite
对于大小写敏感的数据库,如postgresql,需要在配置中传入caselow
配置,否者有可能无法匹配表或字段
Common Query
const DataAccess EmtityClass Single = ; { superarguments0 'id' 'createby'; } // table & emtity ormconst tbconf = userinfo: name: 'userinfo' pk: 'id' ; const ds = type: 'mysql' host: '127.0.0.1' user: 'sa' password: '123456' port: '3506' database: 'ECommerce' multipleStatements: true useConnectionPooling: true;const single = dbconf tbconf; single;
Translate Execute
const DataAccess EmtityClass Public OperationEnum = ; { superarguments0 'id' 'createby'; } // table & emtity ormconst tbconf = userinfo: name: 'userinfo' pk: 'id' ; const ds = type: 'mysql' host: '127.0.0.1' user: 'sa' password: '123456' port: '3506' database: 'ECommerce' multipleStatements: true useConnectionPooling: true;const public = tbconf; const user = id: createby: '123' ;ds;
Bugs
- 修复逻辑非无法插入问题(
数字0
、布尔false
)