Skip to content

Instantly share code, notes, and snippets.

@jdiamond
Created December 30, 2012 18:58
Show Gist options
  • Save jdiamond/4414386 to your computer and use it in GitHub Desktop.
Save jdiamond/4414386 to your computer and use it in GitHub Desktop.
Mongoose as Promised
var mongoose = require('mongoose');
var Q = require('q');
mongoose.Promise.prototype.then = function(fulfilled, rejected) {
var deferred = Q.defer();
this.addCallback(deferred.resolve);
this.addErrback(deferred.reject);
return deferred.promise.then(fulfilled, rejected);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment