 
   constructor: (@_aggregateName, @_eventStore) ->
 
-  findById: (readAggregateName, aggregateId, callback) =>
+  findById: ([readAggregateName]..., aggregateId, callback) =>
+    return unless readAggregateName = @_readAggregateNameNotSet readAggregateName, callback
+
     # create the ReadAggregate instance
     ReadAggregateClass = @getClass readAggregateName
 
     if not ReadAggregateClass
       err = new Error "Tried 'findById' on not registered ReadAggregate '#{readAggregateName}'"
-      callback err, null
-      return
+      return callback err, null
 
     @_eventStore.find @_aggregateName, { 'aggregate.id': aggregateId }, (err, domainEvents) =>
       return callback err, null if err

        )


  findOne: (readAggregateName, query, callback) ->
    @find readAggregateName, query, (err, results) =>
      return callback err, null if err
      return callback null, false if results.length == 0


      callback null, aggregateIds

  _readAggregateNameNotSet: (readAggregateName, callback) ->
    if not readAggregateName
      if not @_readAggregateName
        err = new Error 'No readAggregateName supplied'
        callback err, null
        return false
      else
        readAggregateName = @_readAggregateName

    return readAggregateName


module.exports = ReadAggregateRepository