Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 如何使用nodejs在couchdb中插入文本文件_Node.js_Couchdb - Fatal编程技术网

Node.js 如何使用nodejs在couchdb中插入文本文件

Node.js 如何使用nodejs在couchdb中插入文本文件,node.js,couchdb,Node.js,Couchdb,我使用nodejs生成一个文本文件: fs.writeFile('file.txt',file, err => { if (err) { console.error(err) return } }) 然后我想把这个文件存储到couchDb中。我试过: couch.insertAttachment("databaseName", "document id", "attachment name", "attachment body", "doc revis

我使用nodejs生成一个文本文件:

 fs.writeFile('file.txt',file, err => {
  if (err) {
    console.error(err)
    return
     }
  })
然后我想把这个文件存储到couchDb中。我试过:

couch.insertAttachment("databaseName", "document id", "attachment name", "attachment body", "doc revision").then(({data, headers, status}) => {
    // data is json response
    // headers is an object with all response headers
    // status is statusCode number
}, err => {
    // either request error occured
    // ...or err.code=EFIELDMISSING if either _id or _rev fields are missing
});
但这对我不起作用,我想我弄错了什么。
我以后如何从couchDb获取此文件?

insertAttachment来自何处?@AlexisCôtéi修复了此问题,但是现在我想使用reactjs从couchdb获取所有数据,我尝试了一些解决方案,但是没有人使用const nano=require('nano')(');nano.db.use('books').get('2a0580eb69d3153841a74f29c9007d16')。然后((body)=>{console.log(body);});你所说的所有数据是什么意思?您共享的代码行应该返回相应的正文?