2015 was a big year for mongoose. Mongoose 4.0 was released, the first major release since 3.0 in 2012. Because of CloudUp's acquisition, Mongoose is now under the Automattic GitHub organization. Adoption has grown by leaps and bounds: mongoose was downloaded 935,224 times in December 2015, which is more than the totals for 2012 and 2013 combined. In case you haven't been following mongoose developments closely, here's a recap of some of the big changes in mongoose over the last year.

March 24: New GitHub Home Under Automattic

Mongoose has a somewhat convoluted history. Much of the code was originally written by Guillermo Rauch of LearnBoost. LearnBoost was an ed-tech startup that pivoted to a file-sharing service called CloudUp. CloudUp was subsequently bought by Automattic in 2013. As part of the acquisition, Automattic acquired the IP for mongoose. In March, the mongoose GitHub repo was transferred from the LearnBoost GitHub organization to the Automattic GitHub organization.

As far as development goes, this transfer ended up being cosmetic. I still maintain mongoose as before, Automattic has not opted to get involved, nor are there any Automattic employees actively contributing to mongoose.

March 25: 4.0.0 Released

4.0.0 was a big step forward for mongoose. 4.0.0 introduced the ability to use mongoose schemas in the browser, which enables you to re-use your mongoose schemas for client-side validation. Query middleware is another exciting new feature that enables you to define hooks for find() and findOne() like you do for save() and validate(). Query middleware enables a whole new class of plugins, like plugins for tracking how long queries take. Under the hood, mongoose 4.0.0 also upgraded to version 2.0 of the MongoDB Node.js Driver and fully supports MongoDB server 3.0.

July 24: 4.1.0 Released

The killer feature of mongoose 4.1.0 was the ability to use any ES2015-compatible promises library with mongoose. In other words, you can make mongoose return Bluebird promises with the below line of code.

require('mongoose').Promise = require('bluebird');

For backwards-compatibility, mongoose uses the mpromise library by default. This decision was made in late 2012: bluebird didn't exist until late 2013, and promises weren't introduced into the ES2015 spec until early 2014. Although mpromise is entirely compatible with co and the Promises/A+ spec, ES2015-style promises include features like .catch() and Promise.all() that have become indispensible. By 2015, it became clear that ES6 promises were winning by a wide margin and mpromise was obsolete (although feel free to nag for mpromise to support .catch() on GitHub). As of 4.1.0, mongoose can use whichever ES2015 promise library you want, and mpromise support is now deprecated. If you want to use promises with mongoose, I recommend you start using an ES2015-compatible promise library.

August 1: Mongoose Downloaded 500k Times in July

Mongoose adoption grew dramatically in 2015. Mongoose was downloaded 5x more in December 2015 than December 2014. The 500k downloads milestone was impressive for a module that first broke 200k downloads in November 2014. Thanks to everyone who's been using mongoose so actively over the last year!

October 22: 4.2.0 Released

4.2.0's killer feature was single-embedded schemas. Before 4.2.0, the below schema definition would throw an error.

var childSchema = new Schema({ name: String });
var parentSchema = new Schema({ child: childSchema });

In >= 4.2.0, the above code is perfectly valid, and works with validation and document middleware. For instance:

var childSchema = new Schema({ name: String });

childSchema.pre('validate', function(next) {
  if (!this.ownerDocument().name) {
    return next(new Error('Parent must have a name!'));
  }
  next();
});

var Parent = mongoose.model('Parent',
  new Schema({ child: childSchema, name: String }));

Parent.create({ child: { name: 'test' } }, function(error) {
  // Error: Parent must have a name!
});

Looking Forward To 2016

Thanks to everyone who has used mongoose over the last year: 6 million downloads, 1200 GitHub issues, 1000 commits, and 29 contributors on GitHub. Special thanks to:

  • ChristianMurphy, who has taken on the thankless and long-neglected task of linting the code base for consistent style.
  • chetverikov, who has contributed and helped maintain 4.0's reworked populate features.
  • NoxHarmonium, who singlehandedly made mongoose support X509 authentication.
  • lbeschastny, who bisected a performance degradation that had been introduced 7 months prior.
  • objectiveSee for his work on emitting events after individual index builds and helping respond to questions on the Gitter chat room.
  • andrenarchy for being a consistent early adopter of new features from the 4.x releases and reporting several important bugs.

Happy New Year! Looking forward to a great 2016.

Found a typo or error? Open up a pull request! This post is available as markdown on Github
comments powered by Disqus