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


  constructor: (@_aggregateName, @_eventStore) ->

  findById: (readAggregateName, aggregateId, 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

    @_eventStore.find @_aggregateName, { 'aggregate.id': aggregateId }, (err, domainEvents) =>
      return callback err, null if err


      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