bigbaby-pg
v2.0.26
Published
pg orm
Downloads
7
Readme
// 服务代码
const app = new (require('koa'))();
const koaBody = require("koa-body")
const cors = require('@koa/cors');
app.use(cors());
app.use(koaBody({
formLimit: '20MB',
jsonLimit: '20MB',
textLimit: '20MB',
multipart: true,
includeUnparsed:true,
formidable: {
uploadDir:'d:/uploads',
keepExtensions: true,
maxFileSize: 200 * 1024 * 1024 // 设置上传文件大小最大限制,默认2M
},
}));
const pgdb = require('bigbaby-pg').create(__dirname +'/dbhome' ,'/api/dbop')
//let db =pgdb.getdb('sysdb')
// async function f1() {
// let r = await db.tableSelect({tname:'sys_users'})
// console.log(r)
// }
// f1()
app.use(pgdb.router.routes())
app.listen(1234,()=>{
console.log("server is ok")
})
//数据库链接配置文件示例,放在应用的的dbhome目录下;
const Db = require('bigbaby-pg').Db;
const config = {
user:"pg",
database:"pg",
password:"pg",
host:'127.0.0.1',
port:5432,
max:10, // 连接池最大连接数
idleTimeoutMillis:30000, // 连接最大空闲时间 3s
};
let db = new Db(config, __filename);
module.exports = db;
//在test目录下有 调用实例,可配合kendo grid 后台使用