简体   繁体   English

PouchDB createIndex抛出500错误代码

[英]PouchDB createIndex throws a 500 error code

I am just trying to create a basic index like this 我只是想创建一个像这样的基本索引

 currentDB.createIndex({ index: { fields: ['name'] } }).then((result) => { }).catch((error) => { }) 

But it just sends me a 500 with an 'unknown_error' error message 但这只会向我发送500,带有“ unknown_error”错误消息 在此处输入图片说明

I can successfully run all other methods: .getIndexes, .allDocs, .query etc... only this method is failing for some reason. 我可以成功运行所有其他方法:.getIndexes,.allDocs,.query等...仅此方法由于某种原因而失败。

As mentioned in the documentation : 文档中所述:

500 - Internal Server Error 500内部服务器错误

The request was invalid, either because the supplied JSON was invalid, or invalid information was supplied as part of the request. 由于提供的JSON无效,或者请求中提供了无效信息,因此请求无效。

You need to provide more details to be able to re-produce your situation. 您需要提供更多详细信息才能重现您的情况。


I tired the createIndex API on NodeJS to see if I run into any issue. 我厌倦了createIndex上的createIndex API,看看是否遇到任何问题。 I created the following code in a file named server.js : 我在名为server.js的文件中创建了以下代码:

process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"; // Ignore rejection, becasue CouchDB SSL certificate is self-signed

//import PouchDB from 'pouchdb'
const PouchDB = require('pouchdb')
PouchDB.plugin(require('pouchdb-find'))
const db = new PouchDB('https://admin:****@192.168.1.106:6984/reproduce')

db.createIndex({
    index: {
        fields: ['title']
    }
}).then((result) => {
    console.log(result)
}).catch((error) => {
    console.log(error)
})

When I run the code, the results are fine: 当我运行代码时,结果很好:

$ node server.js 
{ result: 'created',
  id: '_design/94407075806d27d94ac764d9aa138a43c015dc1f',
  name: '94407075806d27d94ac764d9aa138a43c015dc1f' }

So, at least on NodeJS, there shouldn't be any problem with createIndex . 因此,至少在NodeJS上, createIndex应该不会有任何问题。 My PouchDB versions are shown below: 我的PouchDB版本如下所示:

{
  "name": "reproduce-pouchdb-tls",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "pouchdb": "^6.4.3",
    "pouchdb-find": "^6.4.3"
  }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM