// Generated by CoffeeScript 1.7.1
var DBInterface, MongodbInterface,
  __hasProp = {}.hasOwnProperty,
  __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };

DBInterface = require('../../../../src/lib/db/interface.js');

MongodbInterface = (function(_super) {
  __extends(MongodbInterface, _super);

  function MongodbInterface(schema) {
    this.model = schema.getModel();
  }

  MongodbInterface.prototype.create = function(data, cb) {
    return this.model(data).save(cb);
  };

  MongodbInterface.prototype.readOne = function(criteria, cb) {
    return this.model.findOne(criteria, cb);
  };

  MongodbInterface.prototype.readAll = function(criteria, cb) {
    return this.model.find(criteria, cb);
  };

  MongodbInterface.prototype.update = function(criteria, data, options, cb) {
    return this.model.findOneAndUpdate(criteria, data, options, cb);
  };

  MongodbInterface.prototype["delete"] = function(criteria, cb) {
    return this.model.find(criteria).remove(cb);
  };

  return MongodbInterface;

})(DBInterface);

module.exports = MongodbInterface;
