NodeJS and Cradle Not Connecting
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?
This is working for me
Cradle: 0.5.5 Node: 0.5.0-pre
var cradle = require('cradle'),
db;
db = new (cradle.Connection)("duncanm.cloudant.com", {auth:{username:"duncanm", password:"xxxxx"}}).database();
Duncan.
edit: connects, but I cant do anything.. this post has some useful information in it: Connect to Cloudant CouchDB with Node.js?
精彩评论