text: // Generated by CoffeeScript 1.12.7
  (function() {
    module.exports = function(db) {
      return {
        get: function(metrics, username, callback) {
          return db.get("metrics:", function(err, data) {
            var rs;
            metrics = {
              metrics: []
            };
            rs = db.createReadStream();
            rs.on('data', function(data) {
              var regex;
              regex = new RegExp('metrics:' + username);
              if (regex.test(data.key)) {
                return metrics.metrics.push({
                  key: data.key,
                  value: data.value
                });
              }
            });
            rs.on('error', function() {});
            rs.on('close', function() {});
            return rs.on('end', function() {
              console.log(metrics);
              return callback(null, metrics);
            });
          });
        },
        save: function(id, metrics, callback) {
          var i, len, metric, timestamp, value, ws;
          ws = db.createWriteStream();
          ws.on('error', callback);
          ws.on('close', callback);
          for (i = 0, len = metrics.length; i < len; i++) {
            metric = metrics[i];
            timestamp = metric.timestamp, value = metric.value;
            ws.write({
              key: "metrics:" + id + ":" + timestamp,
              value: value
            });
          }
          return ws.end();
        }
      };
    };
  
  }).call(this);
  