 MongoClient = require("mongodb").MongoClient
 
 class MongoDbEventStore extends EventStore
+
+  MONGODB_DUPLICATE_KEY_ERROR_CODE = 11000
+  MIN_RETRY_DELAY                  = 1
+  MAX_RETRY_DELAY                  = 15
+  MAX_RETRIES                      = 10
 
   constructor: ({@uri, @logger}) ->
     throw new Error "Missing URI" unless @uri

        else
          payload["data"][key] = value

      @collection.insert payload, {w:1}, (err, result) ->
        callback err, event

  _find: (params, callback) ->
    p = new Profiler "MongoDbEventStore#_find(db request)", @logger

      return callback err if err?
      @collection.ensureIndex {"aggregateUid": 1}, (err, result) =>
        return callback err if err?
        @collection.ensureIndex {"aggregateUid": 1, "version": 1}, { unique: true }, callback

  createNewUid: (callback) ->
    uid = uuid.v4()
