npm install knex@0.6 --save
npm install sqlite3
var knex = require('knex')({
client: 'sqlite3',
connection: {
filename: "./mydb.sqlite"
}
})
knex.select('title', 'author', 'year').from('books').then(function(r){
console.log(r)
})
npm install knex@0.6 --savenpm install mysql var knex = require('knex')({
client: 'mysql',
connection: {
host : '127.0.0.1',
user : 'your_database_user',
password : 'your_database_password',
database : 'myapp_test'
}
}) knex.select('title', 'author', 'year').from('books').then(function(data){
//取到的数据
console.log(data)
})
更多:
http://knexjs.org/
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)