couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From J Chris Anderson <jch...@gmail.com>
Subject Re: why wont my list function work!?!?
Date Fri, 16 Jul 2010 18:17:29 GMT

On Jul 15, 2010, at 10:09 PM, Steven Prentice wrote:

> i have a view:
> 
> function(doc) {if (doc.docType == 'audit') {
> emit([doc.auditRecord.resourceType, doc.auditRecord.resourceId,
> doc.auditRecord.subResourceType, doc.auditRecord.subResource],
> [doc.auditRecord.auditStamp.createDateTime,
> doc.auditRecord.auditStamp.createdByAccessingSystem,
> doc.auditRecord.auditStamp.createdByAccessingUser, doc._id]);}}
> 
> and a list function:
> 
> {
>   "criteria_filter_sp": "function(head, req){var fromdate =
> \"2010-03-02T07:29:30\";var row;while(row = getRow()){if (fromdate &&
> row.value[0] <= fromdate){send(row.value[4]);}}}"
> }
> 
> the fromDate variable will eventually be a parameter but I have hardocoded
> it for simplicity whilst I learn...
> 
> when i  curl X GET
> http://mycouchserver.net:5984/smpaud/_design/dates/_list/criteria_filter_sp/audit_resource_subresource_with_criteria
> 
> I get {"code":500,"error":"render_error","reason":"function raised error:
> TypeError: chunk is undefined"}
> 

send(row.value[4])

row.value[4] must be empty.
you could do

send(row.value[4] || "I'm on a couch")

to avoid sending undefined.

> ...how can it be undefined if I have literally hardcoded the date??
> 
> S


Mime
View raw message