运行器在 Knex.js 的查询中未定义
Runner is undefined in query of Knex.js
我尝试在Node上使用Knex.js.js通过以下代码:
var Promise = require("bluebird");
var knex = require("knex")({
client: 'pg',
user : 'username',
database : 'database',
password: "password",
migrations: {
tableName: 'knex_migrations'
},
pool: {
min: 0,
max: 7
}
});
knex.select("*").from("users").then(function(rows){
console.log(rows);
});
但是,它抛出了一个关于Runner
对象的错误,如下所示:
/path/to/myapp/node_modules/knex/lib/interface.js:27
return new Runner(this).run().then(onFulfilled, onRejected);
^
TypeError: undefined is not a function
at QueryBuilder_PG.Target.then (/path/to/myapp/node_modules/knex/lib/interface.js:27:12)
at Object.<anonymous> (/path/to/myapp/test.js:14:32)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:906:3
当我尝试使用stream
、pipe
、exec
和transaction
时,发生了同样的错误。
请告诉我如何解决这个问题...
我真的很粗心地对待客户端的配置。我对"连接"的描述是错误的。它必须写成如下:
var Promise = require("bluebird");
var knex = require("knex")({
client: 'pg',
connection: {
host : '127.0.0.1',
user: 'username',
database: 'database',
password: 'password'
},
migrations:{
tableName:"knex_migrations"
},
pool: {
min: 0,
max: 7
}
});
knex.select("*").from("users").then(function(rows){
console.log(rows);
});
它工作没有问题。
谢谢!
相关文章:
- jqueryajax生成查询字符串,如果未定义则不通过
- *简单*解析云代码查询失败”;TypeError:无法调用方法'获取'未定义的“检索该信息”;
- 类型错误:无法读取未定义的 mysql 查询的属性“名称”
- 在IE8中查询未定义的变量
- 查询 TaffyDB - 查询未定义的列值
- j查询工具提示引发错误:未定义函数
- 猫鼬,函数不能在未定义的、来自查询函数上执行
- 余烬数据断言失败:无法对未定义的对象使用“查询”调用 get
- 运行器在 Knex.js 的查询中未定义
- 数据库查询在 node.js 中使用 oracledb 返回未定义的值
- 解析查询“无法调用未定义的方法'等于'”
- 帆查询不断呈现未定义的对象
- Grunt Combine媒体查询-无法调用方法“”;加入“;的未定义
- 正在分析查询,但结果显示为未定义或找不到
- Meteor findOne查询在一个模板助手中返回未定义的结果.在其他模板助手中,同样的查询也能很好地工作
- Node.js:数据库查询后返回值未定义
- 在Javascript中使用SQL查询时遇到未定义函数错误
- 类型错误:试图将未定义的属性查询包装为函数
- 在TaffyDB查询中使用JS变量返回未定义
- 函数的返回值在Sqllite executeSql查询javascript中显示为未定义