edt*_*edt 2 couchdb node.js cradle
初学者问题.
以下是Cradle CouchDB文档中给出的示例:https: //github.com/cloudhead/cradle
什么是5984?
new(cradle.Connection)('http://living-room.couch', 5984, {
cache: true,
raw: false
});
Run Code Online (Sandbox Code Playgroud)
我正试图从我的couchdb获取信息:
url:subdomain.mywebsite.com
节点端口:12345
couchdb port:67891
我已尝试使用上述代码进行连接的不同方法,但我得到以下错误.
什么是正确的连接方式?
17 May 09:50:57 - [nodemon] restarting due to changes...
17 May 09:50:57 - [nodemon] ./test_couch.js
17 May 09:50:57 - [nodemon] starting node
Server running somewhere
request starting...
request starting...
node.js:181
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: ECONNREFUSED, Connection refused
at Socket._onConnect (net.js:602:18)
at IOWatcher.onWritable [as callback] (net.js:186:12)
17 May 09:51:05 - [nodemon] app crashed - waiting for file change before starting...
Run Code Online (Sandbox Code Playgroud)
从您发布链接的相同文档中,但仅在此JS文件中的代码文件夹中https://github.com/cloudhead/cradle/blob/master/lib/cradle.js
cradle.Connection = function Connection(/* variable args */) {
var args = Array.prototype.slice.call(arguments),
host, port, remote, auth, options = {};
args.forEach(function (a) {
if (typeof(a) === 'number' || (typeof(a) === 'string' && /^\d{2,5}$/.test(a))) {
port = parseInt(a);
} else if (typeof(a) === 'object') {
options = a;
host = host || options.host;
port = port || options.port;
auth = options.auth;
} else {
host = a;
}
});
Run Code Online (Sandbox Code Playgroud)
所以它需要你给它的任何参数,并将其切成一个数组.
什么是5984?
这是连接的端口,正如我分享的这段代码片段所示.
它实际上接受三种类型的参数,一个端口(长度在2到5位之间)的数字,一个字符串和一个用于配置的对象.
您只能提供一个对象并将其声明部分声明为:
new(cradle.Connection)({
host: 'http://living-room.couch',
port: 67891,
cache: true,
raw: false
});
Run Code Online (Sandbox Code Playgroud)
它会工作相同的
| 归档时间: |
|
| 查看次数: |
1708 次 |
| 最近记录: |