NodeJS 和 Cradle 未连接
使用 Cradle 5.5 和 NodeJS 0.4.8,我似乎无法建立工作连接。我已经成功使用RESTLER,但我似乎无法配置摇篮。我想利用 Cradle 的缓存功能。
我已经尝试过我的 Cloudant 帐户和普通的管理方 CouchDB 数据库,两者都具有相同的结果。
管理方数据库:
var conn1 = new (cradle.Connection)("XX.XX.XXX.XXX", 5984);
Cloudant:
var account = {
username: "user",
password: "pwd"
};
var conn = new (cradle.Connection)("user.cloudant.com", 443, {
secure: true,
auth: account
});
我已经尝试了所有组合,似乎没有任何其他效果当我执行诸如 console.log(conn.config());
或 console.log(conn.databases());
之类的事情时,比未定义
任何关于可能是什么的想法造成这个?我开始认为这可能是 Cradle/NodeJS 的版本,但我似乎找不到它们在任何地方都不一起工作的参考。
更新:仍然有问题,但我稍微更改了代码,看看是否可以查明问题。
cradle.setup({host:'username.cloudant.com', port: 443,
auth: { username: 'username', password: 'password'},
options: {secure: true, cache: true, raw: false}
});
c = new(cradle.Connection)().config();
console.log(c);
console.log(cradle);
我的输出如下:
undefined
{ extend: [Function],
Response: [Function: Response],
Cache: [Function],
host: 'username.cloudant.com',
port: 443,
auth: { username: 'username', password: 'password' },
options:
{ cache: true,
raw: false,
timeout: 0,
secure: false,
headers: {},
host: 'username.cloudant.com',
port: 443,
auth: { username: 'username', password: 'password' },
options: { secure: true, cache: true, raw: false } },
setup: [Function],
Connection: [Function: Connection],
merge: [Function] }
我非常困惑——其他人至少以前经历过这种情况吗?
Using Cradle 5.5 and NodeJS 0.4.8, I can't seem to get a connection to work. I've successfully used RESTLER, but I can't seem to configure cradle. I'd like to take advantage of the caching aspects of Cradle.
I've tried both my Cloudant Account and a normal, admin party CouchDB database, both with the same results.
Admin Party Database:
var conn1 = new (cradle.Connection)("XX.XX.XXX.XXX", 5984);
Cloudant:
var account = {
username: "user",
password: "pwd"
};
var conn = new (cradle.Connection)("user.cloudant.com", 443, {
secure: true,
auth: account
});
I've tried all combinations, nothing seems to get me anything other than undefined when I do things like console.log(conn.config());
or console.log(conn.databases());
Any ideas on what might be causing this? I am starting to think it might be the versions of Cradle/NodeJS, but I can't seem to find a reference to them to not working together anywhere.
UPDATE: Still having issues, but I changed the code a bit to see if I could pinpoint the problem.
cradle.setup({host:'username.cloudant.com', port: 443,
auth: { username: 'username', password: 'password'},
options: {secure: true, cache: true, raw: false}
});
c = new(cradle.Connection)().config();
console.log(c);
console.log(cradle);
My output is the following:
undefined
{ extend: [Function],
Response: [Function: Response],
Cache: [Function],
host: 'username.cloudant.com',
port: 443,
auth: { username: 'username', password: 'password' },
options:
{ cache: true,
raw: false,
timeout: 0,
secure: false,
headers: {},
host: 'username.cloudant.com',
port: 443,
auth: { username: 'username', password: 'password' },
options: { secure: true, cache: true, raw: false } },
setup: [Function],
Connection: [Function: Connection],
merge: [Function] }
I'm incredibly stumped-anyone else at least experienced this before?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这对我有用
摇篮:0.5.5
节点:0.5.0-
Duncan 之前。
编辑:连接,但我无能为力..这篇文章中有一些有用的信息:
使用 Node.js 连接到 Cloudant CouchDB?
This is working for me
Cradle: 0.5.5
Node: 0.5.0-pre
Duncan.
edit: connects, but I cant do anything.. this post has some useful information in it:
Connect to Cloudant CouchDB with Node.js?