【发布时间】:2017-02-01 16:16:08
【问题描述】:
我正在构建一个这样的 CouchDB 设计文档:
const ddoc={
"_id":"_design/index2nd",
"views":{
"by_id":{
"map": (function(doc){emit(doc._id, doc);}).toString()
},
"by_username":{
"map": (function(doc){emit(doc.username, doc);}).toString()
}
}
}
我正在保存设计文档:
db.put(ddoc).then(()=>{
////done!
}).catch(err=>{
console.log('error: design doc is not saved: ', err)
})
在您查询它之前不会构建索引,因此我执行一个空查询来启动一个新构建:
db.query("index2nd/by_id",{
limit:0 // don't return any results
}).then(result=>{
// index was built!
}).catch(err=>{
console.log('error: index2nd/by_id is not built: ', err)
})
db.query("index2nd/by_username",{
limit:0//don't return any results
}).then(result=>{
//index is built
}).catch(err=>{
console.log('error: index2nd/by_username is not built: ', err)
})
但是我收到以下错误:
错误:index2nd/by_id 未构建:{ 错误:'not_found', 原因:'删除', 名称:'not_found', 状态:404, 消息:“已删除”}
错误:index2nd/by_username 未构建:{ 错误:'not_found', 原因:'删除', 名称:'not_found', 状态:404, 消息:“已删除”}
【问题讨论】:
标签: javascript view couchdb