couchdb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jan Lehnardt <...@apache.org>
Subject Re: CoffeeScript CommonJS Module Function
Date Tue, 20 Aug 2013 20:51:31 GMT

On Aug 20, 2013, at 22:49 , Anthony Kaufman <anthony.kaufman@gmail.com> wrote:

> I finally gave up and just compiled my CoffeeScripts to Javascript before I saved them
into Couch. That way I can maintain the scripts in CoffeeScript (which I like), and  store
them as Javascript (which CouchDB apparently likes). I had a script which was automating the
save anyway so this wasn't too tricky (now I'm just bragging).
> 
> I still think that this could be a real live bug, or lack of a feature anyway. Where
would be the best place to report something like that?

http://issues.apache.org/jira/browse/COUCHDB :)

Thanks!

I agree this is a bug and should be fixed. Maybe https://github.com/apache/couchdb/blob/master/share/server/util.js#L13
and following give you a clue why this might fail in CS?

Best
Jan
-- 

> 
> Thanks, Anthony
> 
> On Aug 16, 2013, at 2:03 PM, Anthony Kaufman <anthony.kaufman@gmail.com> wrote:
> 
>> I've been trying to define a CoffeeScript CommonJS Module Function without success.
I can translate the same function into Javascript and it works fine. I'm using CouchDB 1.3.1
on Mac OS X Lion.
>> 
>> Here's the CoffeeScript document:
>> {
>> 	_id: "_design/test",
>> 	language: "coffeescript",
>> 	lib: {
>> 		say_hello: "exports.callback = (name) -> 'Hello ' + name"
>> 	}
>> 	test: {
>> 		map: "(doc) ->
>> 	say_hello = require('views/lib/say_hello').callback
>> 	emit(say_hello(doc._id), doc)"
>> 	}
>> }
>> 
>> When ran, it returns the following errors for each document:
>> function raised exception (new TypeError("say_hello is not a function", "undefined",
5)) with doc._id
>> 
>> Here's the Javascript document which works just fine:
>> {
>> 	_id: "_design/test",
>> 	language: "javascript",
>> 	lib: {
>> 		say_hello: "exports.callback = function(name) { return 'Hello ' + name }"
>> 	}
>> 	test: {
>> 		map: "function(doc) { say_hello = require('views/lib/say_hello').callback; emit(say_hello(doc._id),
doc) }"
>> 	}
>> }
>> 
>> Currently, I have all of my views in a real document defined in CoffeeScript and
I'd really rather not convert them all to Javascript. Any help would be appreciated.
>> 
>> - Anthony
> 


Mime
View raw message