# think-knex **Repository Path**: byhgj/think-knex ## Basic Information - **Project Name**: think-knex - **Description**: thinkjs扩展knex功能,支持firebird - **Primary Language**: NodeJS - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2018-01-04 - **Last Updated**: 2021-11-27 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README thinkjs不支持firebird,knex功能强大,集成到一起(未集成到model,单独做一个插件) 安装支持firebird的knex npm install --save knex-firebird 配置, /src/config/adapter.js ```js exports.knex = { type: 'test', test: { client: 'firebird', connection: { host: '127.0.0.1', user: 'test', password: 'test', database: '/usr/db/test.fdb' } } }; ``` 应用到app, /src/config/extend.js ```js ... const knex = require('think-knex'); module.exports = [ ..., knex(think.app) ]; ``` 控制器示例 ```js const Base = require('./base.js'); module.exports = class extends Base { async indexAction() { let rows = await this.knex.table('test') .limit(5) .select('id,name,code') //.then( rows => { // rows.forEach( row => { // console.log(row); // }); //}) ; return this.body = rows[0]; //return this.display(); } }; ``` 1.05支持同一个系统多个数据库 ```js module.exports = class extend Base { __before() { this.m = this.knexInstance('在adapter中配置'); } testAction(){ await this.m('test').select(); } } ```