Couchdb 和 pouchdb 没有在同一个地方存储信息
Couchdb and pouchdb are not storing info in the same place
我对 couchdb / pouchdb 有点困惑。
这是我的设置。
我正在 运行宁 couchdb
准备好 运行宁。
确认我运行这个,curl localhost:5984
,它有效。
导航至 http://localhost:5984/_utils/index.html
并查看:
然后我使用node
和pouchdb
连接并插入文档。
var PouchDB = require('pouchdb')
var test = new PouchDB('test')
test.info()
.then(function (info) {
console.log(info)
})
.catch(console.error)
test.put({
'_id': '308',
'hello': 'world'
})
.then(console.log)
.catch(console.error)
我 运行 这个 node index.js
并且都得到了好的响应。
我检查了 couchdb
管理员(上图),发现它没有改变。好像没有保存数据。
我查看节点项目目录,发现有一个 test
文件夹。肯定有一些问题 pouch 认为数据库目录是本地的,而 couchdb
目录在其他地方。
为了找出沙发存储信息的位置,我 运行 couchdb -c
$ couchdb -c
/usr/local/etc/couchdb/default.ini
/usr/local/etc/couchdb/local.ini
这给了我配置文件的位置。
我可以在 default.ini
中看到这个:
database_dir = /usr/local/var/lib/couchdb
view_index_dir = /usr/local/var/lib/couchdb
我不明白 couchdb
认为数据库所在的位置与 pouchdb
认为它所在的位置之间的这种联系有何不同。
我该如何解决这个问题,并使 pouchdb
使用为 couchdb
指定的目录?
更新:
刚刚试过了,我仍然没有在 couchdb
界面中看到它。
var PouchDB = require('pouchdb')
// var test = new PouchDB('test')
var MyPrefixedPouch = PouchDB.defaults({
prefix: '/usr/local/var/lib/couchdb'
});
var test = new MyPrefixedPouch('test');
test.info().then(function (info) {
console.log(info)
})
test.put({
'_id': '308',
'hello': 'world'
})
.then(console.log)
.catch(console.error)
我认为您不了解 pouchdb 的工作方式。当您 运行 它以您现在的方式在节点中使用 leveldb 作为后端时。它正在你项目的测试目录中写入一个数据文件(我想知道如果你在那里进行测试会发生什么!)。
它根本不与您的 couchbase 服务器通信。
如果您在构造函数中将 uri 传递给您的 couch 服务器,您将与您的 couchbase 实例对话:
var remoteDB = new PouchDB('http://localhost:5984/myremotedb')
我对 couchdb / pouchdb 有点困惑。
这是我的设置。
我正在 运行宁 couchdb
准备好 运行宁。
确认我运行这个,curl localhost:5984
,它有效。
导航至 http://localhost:5984/_utils/index.html
并查看:
然后我使用node
和pouchdb
连接并插入文档。
var PouchDB = require('pouchdb')
var test = new PouchDB('test')
test.info()
.then(function (info) {
console.log(info)
})
.catch(console.error)
test.put({
'_id': '308',
'hello': 'world'
})
.then(console.log)
.catch(console.error)
我 运行 这个 node index.js
并且都得到了好的响应。
我检查了 couchdb
管理员(上图),发现它没有改变。好像没有保存数据。
我查看节点项目目录,发现有一个 test
文件夹。肯定有一些问题 pouch 认为数据库目录是本地的,而 couchdb
目录在其他地方。
为了找出沙发存储信息的位置,我 运行 couchdb -c
$ couchdb -c
/usr/local/etc/couchdb/default.ini
/usr/local/etc/couchdb/local.ini
这给了我配置文件的位置。
我可以在 default.ini
中看到这个:
database_dir = /usr/local/var/lib/couchdb
view_index_dir = /usr/local/var/lib/couchdb
我不明白 couchdb
认为数据库所在的位置与 pouchdb
认为它所在的位置之间的这种联系有何不同。
我该如何解决这个问题,并使 pouchdb
使用为 couchdb
指定的目录?
更新:
刚刚试过了,我仍然没有在 couchdb
界面中看到它。
var PouchDB = require('pouchdb')
// var test = new PouchDB('test')
var MyPrefixedPouch = PouchDB.defaults({
prefix: '/usr/local/var/lib/couchdb'
});
var test = new MyPrefixedPouch('test');
test.info().then(function (info) {
console.log(info)
})
test.put({
'_id': '308',
'hello': 'world'
})
.then(console.log)
.catch(console.error)
我认为您不了解 pouchdb 的工作方式。当您 运行 它以您现在的方式在节点中使用 leveldb 作为后端时。它正在你项目的测试目录中写入一个数据文件(我想知道如果你在那里进行测试会发生什么!)。
它根本不与您的 couchbase 服务器通信。
如果您在构造函数中将 uri 传递给您的 couch 服务器,您将与您的 couchbase 实例对话:
var remoteDB = new PouchDB('http://localhost:5984/myremotedb')