 class Space.eventSourcing.Snapshotter extends Space.Object
+
+  ERRORS:
+    noSnapshotFound: (id) -> new Error "No snapshot was found for aggregate <#{id}>"
 
   _collection: null
   _versionFrequency: 0

    @_versionFrequency = config.versionFrequency

  makeSnapshotOf: (aggregate) ->
    id = aggregate.getId()
    currentVersion = aggregate.getVersion()
    data = @_collection.findOne _id: id


      @_collection.insert _id: id, snapshot: aggregate.getSnapshot()

  getSnapshotOf: (Type, id) ->
    id = id.toString()
    record = @_collection.findOne(_id: id)
    if record?
      return Type.createFromSnapshot record.snapshot
    else
      throw @ERRORS.noSnapshotFound(id)
