English 中文(简体)
CouchDB 返回“ 不对函数进行评估”
原标题:CouchDB returns "does not eval to a function"
  • 时间:2012-05-23 14:48:03
  •  标签:
  • couchdb

我有这个密码

 {
    "_id": "_design/test",
    "_rev": "10-651aa6314effdad0bca00fc4a3da38f6",
    "views": {
       "foo": {
           "map": "(function(doc){ emit(doc._id, doc._rev)})"
       },
       "bar": {
           "map": "(function(doc){if(doc.date && doc.title) {emit(doc.date, doc.title);})"
       }
      }
    }

为什么它返回一个:

表达式不是对函数的 eval 。 (( 新 String ("( 函数( doc) ) { (doc. date& & amp; doc. title) {emit (doc. date, doc. title);}} ) )

最佳回答

我知道这个问题已经过去,答案实际上是在对问题的评论中,但似乎应该公布一个答案。

函数的最后圆括号缺失。缩进后,它看起来像如下:

function(doc) {
  if (doc.date && doc.title) {
    emit(doc.date, doc.title);
  }
}

注意最后一行的两支支支架:

function(doc){if(doc.date && doc.title){emit(doc.date, doc.title);}}

我更喜欢缩进和使用空间, 所以我不会错过那些东西。

问题回答

暂无回答




相关问题
couchdb for /really/ distributed replica

let s say i want to implement a distributed database (each node being the replica of the others); i hear that cdb is able to easily sync between two nodes and at least support some form of conflict ...

CouchDB View, Map, Index, and Sequence

I think read somewhere that when a View is requested the "map" is only run across documents that have been added since the last time it was requested? How is this determined? I thought I saw something ...

representing a many-to-many relationship in couchDB

Let s say I m writing a log analysis application. The main domain object would be a LogEntry. In addition. users of the application define a LogTopic which describes what log entries they are ...

couchDB , python and authentication

I have installed couchDB v 0.10.0, and am attempting to talk to it via python from Couch class downloaded from couchDB wiki. Problem is: Create database mydb : { error : unauthorized , reason : ...

Temp View Caching?

I m using CouchDB with a home-grown C# interface library. The most common method of accessing CouchDB with this library results in a temp view being created. I ve optimized the library so that it uses ...

热门标签