
var mongoose = require('mongoose');
mongoose.connect(process.env.MONGO_URI);

mongoose.Model.prototype.psave = function () {

    var that = this;

    return new Promise(function (resolve) {

        that.save(function (err) {

            if (err) {
                throw err
            }

            resolve();

        });

    });

};


var Tomato = mongoose.model('Tomato', {
    title: String,
    notes: String,
    mood: String,
    performance: Number,
    startedAt: Date,
    endedAt: Date,
    interupted: Boolean,
    finished: Boolean,
    accountId: String
});

var Account = mongoose.model('Account', {
    id: String,
    name: String
});


module.exports.Tomato = Tomato;
module.exports.Account = Account;

@@ -34,49 +34,298 @@
 ');%0A
-mongoose.connect(process.env.MONGO_URI);%0A
+%0A// polyfill of catch%0A// https://github.com/aheckmann/mpromise/pull/14%0Arequire('mongoose/node_modules/mpromise').prototype.catch = function (onReject) %7B%0A    return this.then(undefined, onReject);%0A%7D;%0A%0Amongoose.connect(process.env.MONGO_URI);%0A%0A/**%0A * Saves the model and returns a promise%0A */
 %0Amon
@@ -889,23 +889,174 @@
     
-name: String%0A%7D)
+displayName: String,%0A    facebookId: String%0A%7D);%0A%0AAccount.prototype.picture = function () %7B%0A%0A    return 'http://graph.facebook.com/' + this.facebookId + '/picture';%0A%0A%7D
 ;%0A%0A%0A

Modify model and add polyfill of promise.catch