Cradle CouchDB,cradle.Connection 函数参数是什么?
初学者问题。
下面是 Cradle CouchDB 文档中给出的示例: https://github.com/cloudhead/cradle
5984是什么?
new(cradle.Connection)('http://living-room.couch', 5984, {
cache: true,
raw: false
});
我正在尝试从我的 couchdb 获取信息:
url: subdomain.mywebsite.com
节点端口: 12345
couchdb 端口: 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...
Beginner Question.
Below is an example given on the Cradle CouchDB documentation:
https://github.com/cloudhead/cradle
What is http://living-room.couch?
What is 5984?
new(cradle.Connection)('http://living-room.couch', 5984, {
cache: true,
raw: false
});
I'm trying to get info from my couchdb:
url: subdomain.mywebsite.com
node port: 12345
couchdb port: 67891
I've tried different ways to connect using the above code, but I get the below error.
What is the right way to connect?
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...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
来自您发布链接的同一文档,但仅在此 JS 文件中的代码文件夹中 https://github.com/cloudhead/cradle/blob/master/lib/cradle.js
所以它会接受你给它的任何参数,并将其切片到一个数组中。
正如我共享的代码片段所示,这是要连接的端口。
它实际上接受三种类型的参数:端口号(长度在 2 到 5 位之间)、字符串和配置对象。
您可以只提供一个对象并将其部分声明为:
并且它的工作原理相同
From the same documentation that you posted a link to, but only in the code folder here in this JS file https://github.com/cloudhead/cradle/blob/master/lib/cradle.js
So it takes whatever parameters you give it, and slices it into an array.
It's the port to connect to, as evinced by this code snippet I shared.
It accepts really three types of parameters, a port (between 2 and 5 digits in length) number, a string, and an object for configuration.
You could supply just one object and declare the parts of it as this:
and it would work the same