var bookshelf = require('bookshelf'),
    config    = require('../config'),

    db        = bookshelf.initialize(config.db);

var _toJSON = db.Model.prototype.toJSON;

db.Model.prototype.toJSON = function(options) {
    options = options || {};
    options.noPivot = options.noPivot || true;

    return _toJSON.call(this, options);
};

var Owner     = db.Model.extend({
    tableName: "owners",
});

var Bot       = db.Model.extend({
    tableName: "bots",

    toJSON: function() {
        var json = db.Model.prototype.toJSON.call(this);
        delete json.path;
        return json;
    },

    games: function() {
        return this.belongsToMany(Game).through(Competitor, "bot", "game");
    }
})

var Game      = db.Model.extend({
    tableName: "games",
    bots: function() {
        return this.belongsToMany(Bot).through(Competitor, "game", "bot");
    }
});

var Battle    = db.Model.extend({
    tableName: "battles",
});

var Competitor = db.Model.extend({
    tableName: "competitors",

    game: function() {
        return this.belongsTo(Game, "game");
    },

    bot: function() {
        return this.belongsTo(Bot, "bot");
    }
});

module.exports = {
    "Owner": Owner,
    "Bot": Bot,
    "Game": Game,
    "Battle": Battle,
    "Competitor": Competitor,
};

@@ -698,16 +698,17 @@
     %7D%0A%7D)
+;
 %0A%0Avar Ga

missing semicolon