Static methods in coffeescript and node

I'm fairly new to using coffeescript and I have the following code

eventBus = require './eventBus'                      

class Aggregate                                       
  constructor(id) ->                                  
    @_id = id                                         

  @find: (id) ->                                                              
    console.log "Find Called"
    new Aggregate(id)                                                 

  @apply: (event) ->                                                          
    @_total += event.attribute.amount                                         

  @emit: (event) ->                                                           
     EventBus.store event                                                     

module.Aggregate = Aggregate

The problem I have is I want to call Aggregate.find 20 which in turn will return a new aggregate with that ID. Any advice on how to get this module to work like this would be greatly appreciated.

Cheers Mike.

Your code should work fine, except that you have a syntax error in your constructor.

Change:

constructor(id) ->

to:

constructor: (id) ->

Append this somewhere:

Aggregate.find = (id) ->                                                              
  console.log "Find Called"
  new Aggregate(id)                                                 

And it would be "static" method.