gpt4 book ai didi

javascript - CouchDB 查看搜索中的空白空间

转载 作者:行者123 更新时间:2023-11-28 20:48:54 24 4
gpt4 key购买 nike

我正在尝试使用蒲团中的临时 View 在 couchDb 中进行搜索。

查看代码是这样的:

function(doc)
{
if(doc.Time Zone.value == "America/Los_Angeles")
{
emit([doc.owner, doc.source], null);
}
}

但是当我尝试阳光这个 View 时,它给出以下错误:错误:编译错误

表达式不等于函数。 ((new String("function(doc)) { if(doc.Time Zone.value ==\"美国/洛杉矶\") { 发出([doc.owner, doc.source], null); } }")) )

我认为这是因为 doc.Time Zone 中存在空格。如果删除此空间,它会编译但不会给出任何值。编译器不需要这个空白空间。

请帮助我。

最佳答案

这是因为您访问文档的时区字段的方式无效。

访问该字段的正确方法是

doc['Time Zone'].value

这是您面临的一个基本 JavaScript 问题。

关于javascript - CouchDB 查看搜索中的空白空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12891660/

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