gpt4 book ai didi

javascript - 如何使用 couchdb 列表函数从 couchdb View 结果中获取特定字段

转载 作者:行者123 更新时间:2023-12-03 10:54:20 24 4
gpt4 key购买 nike

下面我提到了设计文档。

       {
"_id": "_design/link",
"_rev": "62-0c0f00dd9dbedab5c2cca61c356bbff4",
"views": {
"link": {
"map": "function(doc) {\n if (doc.projects) { for (var i in doc.projects) { emit(doc._id, {_id: doc.projects[i].proj_id}); }} \n}"
},
"lists": {
"sample": "function(head, req) {while(row = getRow()){ send(row.doc.proj_name);} }"
}
}

}

查看结果:

{
total_rows: 1,
offset: 0,
rows: [
{
id: "SCI130202",
key: "SCI130202",
value: {
_id: "PID00034"
},
doc: {
_id: "PID00034",
_rev: "1-0a363e98a605a72fd71bb4ac62e0b138",
client_id: "E000022",
client_name: "Edinburgh Steel",
type: "manage projects",
proj_id: "PID00034",
proj_name: "Global_upgrade_Oracle",
proj_domain: "Information Technology",
proj_start_date: "2014-10-08",
proj_end_date: "2015-07-07",
delivery_manager: null,
proj_standards: null,
proj_currency_type: "INR",
onsite: "No",
location: "Edinburgh",
proj_status: "Noy yet Start",
budgeted_margin: 45,
budgeted_hrs: 300,
projected_revenue: 200000,
billing_rate: 30,
unit_measure: "per month",
billing_cycle: "Milestone",
proj_core_tech_skills: [ ],
proj_secon_skills: [ ],
proj_sdlc_skills: [ ],
tag: "",
margin: [
{
desired_onsite: null,
desired_offshore: null,
lower_limit: null
}
]
}
}
]

}

我尝试过,但错误如下

函数引发错误:(new TypeError("row.doc is undefined", ""))如何使用couchdb列表函数获取proj_name、proj_start_date和proj_end_date?

最佳答案

您需要将 include_docs=true 选项添加到用于查询 View /列表的 URL。 View 不会自动包含文档。

关于javascript - 如何使用 couchdb 列表函数从 couchdb View 结果中获取特定字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28319094/

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