incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jim Garvin <coderif...@gmail.com>
Subject Re: Default values via _updates function
Date Tue, 02 Mar 2010 14:44:14 GMT
*Chris,*

Thanks for the response.

$ couchdb -V
couchdb - Apache CouchDB 0.10.1

Judging by the CouchDB downloads
page<http://couchdb.apache.org/downloads.html>,
I'm on the latest stable release.  I was trying to get a sense of how far
off 0.11 is, so I referred to the road
map<http://couchdb.apache.org/roadmap.html> which
looks like it might be out of date, and then to the JIRA
issues<https://issues.apache.org/jira/secure/IssueNavigator.jspa?reset=true&mode=hide&sorter/order=DESC&sorter/field=priority&resolution=-1&pid=12310780&fixfor=12313841>
for
0.11, which didn't really help either.

Is CouchDB a project where it would be ill-advised to run on "edge" to get
some 0.11 features early?  I'll try just updating SpiderMonkey, as you
suggested, first.

Thanks much.

*Mario*,

Also, thanks for the response.  As a shot in the dark, I had tried parseJSON
first to no avail.

Thanks again to both,
Jim


On Mon, Mar 1, 2010 at 6:06 PM, Mario Scheliga <mario@sourcegarden.de>wrote:

> Hi Jim,
>
> forget my last answer... sorry just grepped the source.... i think chris is
> right!
>
> greetz
>
> mario
>
> Am 01.03.2010 um 23:53 schrieb Jim Garvin:
>
>  Hi All,
>>
>> I'm trying to do server-side created_at timestamps via CouchDB's _updates
>> features, but I'm having trouble creating a new document out of the JSON
>> passed in the request body.  My app doesn't allow updates to existing
>> documents, only "inserts".  Here's the very simple _updates function:
>>
>> function(doc, req) {
>>  var newDoc = JSON.parse(req.body);
>>  newDoc.created_at = new Date();
>>  return [newDoc, "FML"];
>> }
>>
>> When I POST a document to the appropriate _updates URL, I get an error in
>> the log telling me that JSON is not defined:
>>
>> [info] [<0.30422.5>] OS Process :: function raised error: ReferenceError:
>> JSON is not defined
>>
>> I wasn't able to find much reference on the web aside from:
>>
>> http://wiki.apache.org/couchdb/How_to_intercept_document_updates_and_perform_additional_server-side_processing
>> http://www.mikealrogers.com/archives/737
>>
>> In the mikealrogers.com post, the author uses JSON in his function, but
>> obviously I'm having problems with that approach.  Does anyone know what a
>> proper way to convert the body of the POST a javascript object would be?
>> (avoiding eval()).  Also, taking a step back, is this the right approach
>> for setting default values on a new document in CouchDB?
>>
>> Thanks,
>> Jim
>>
>
>
> --
> Sourcegarden GmbH HR: B-104357
> Steuernummer: 37/167/21214 USt-ID: DE814784953
> Geschaeftsfuehrer: Mario Scheliga, Rene Otto
> Bank: Deutsche Bank, BLZ: 10070024, KTO: 0810929
> Schoenhauser Allee 51, 10437 Berlin
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message