mattdaly/node-ravendb — Issue #12: Better 'Document' support for JS
Author: mattdaly
Created: 2012-01-04 01:47:01+00:00
State: open

Previous version was written in JS and allowed for var Reindeer = new Document('Reindeer') like declarations, but I wanted to give coffeescript a try.

Coffeescript classes are wrapped in anonymous functions, so using new Document('Reindeer') returns the object, not the 'object function' which doesn't work for types, you have to use coffeescripts class xxxx extend Document syntax.

Current solution just creates a new object and builds it, returning the object function via a static method for use in JS (e.g. var Reindeer = Document.extends('Reindeer');), but this basically replicates the coffeescript class and provides a way to return it to JS - DRY. Find a better solution.