 # A super simple mongodb adapter for itsalive
+
+shallowClone = (object) ->
+  out = {}
+  out[key] = object[key] for key of object
+  return out
 
 # mongo is a mongoskin client. Create with:
 #  mongo.db('localhost:27017/tx?auto_reconnect', safe:true)



  queryDoc: (cName, docName, query, callback) ->
    query = JSON.parse JSON.stringify query # clone the query so we don't edit the original
    query._id = docName
    mongo.collection(cName).findOne query, (err, result) ->
      if result
        result.docName = docName

  query: (cName, query, callback) ->
    return callback 'db already closed' if @closed

    # Clone the query so we don't edit the original
    query = shallowClone query
    query.type = {$ne: null} unless query.type

    skip = query.$skip
    limit = query.$limit

    mongo.collection(cName).find query, (err, cursor) ->
      return callback err if err
