NodeJS 和 Cradle 未连接

发布于 2024-11-18 23:18:35 字数 1663 浏览 8 评论 0原文

使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

善良天后 2024-11-25 23:18:35

这对我有用

摇篮:0.5.5
节点:0.5.0-

var cradle = require('cradle'),
    db;


db = new (cradle.Connection)("duncanm.cloudant.com", {auth:{username:"duncanm", password:"xxxxx"}}).database();

Duncan 之前。

编辑:连接,但我无能为力..这篇文章中有一些有用的信息:
使用 Node.js 连接到 Cloudant CouchDB?

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?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文