gpt4 book ai didi

javascript - PouchDB createIndex 抛出 500 错误代码

转载 作者:行者123 更新时间:2023-12-03 02:02:59 26 4
gpt4 key购买 nike

我只是想创建一个像这样的基本索引

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

}).catch((error) => {

})

但它只是向我发送了带有“unknown_error”错误消息的 500 enter image description here

我可以成功运行所有其他方法:.getIndexes、.allDocs、.query 等...只有此方法由于某种原因失败。

最佳答案

documentation 中所述:

500 - Internal Server Error

The request was invalid, either because the supplied JSON was invalid, or invalid information was supplied as part of the request.

您需要提供更多详细信息才能重现您的情况。

<小时/>

我厌倦了 NodeJS 上的 createIndex API,看看是否遇到任何问题。我在名为 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)
})

当我运行代码时,结果很好:

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

所以,至少在 NodeJS 上,createIndex 不应该有任何问题。我的 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"
}
}

关于javascript - PouchDB createIndex 抛出 500 错误代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49930022/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com