release 3.5.0

399 views
Skip to first unread message

Aaron Heckmann

unread,
Dec 11, 2012, 1:24:10 PM12/11/12
to mongoo...@googlegroups.com

3.5.0 / 2012-12-10
==================

  * added; paths to CastErrors #1239
  * added; support for mongodb connection string spec #1187
  * added; post validate event
  * added; Schema#get (to retrieve schema options)
  * added; VersionError #1071
  * added; npmignore [hidekiy](https://github.com/hidekiy)
  * update; driver to 1.2.3
  * fixed; stackoverflow in setter #1234
  * fixed; utils.isObject()
  * fixed; do not clobber user specified driver writeConern #1227
  * fixed; always pass current document to post hooks
  * fixed; throw error when user attempts to overwrite a model
  * fixed; connection.model only caches on connection #1209
  * fixed; respect conn.model() creation when matching global model exists #1209
  * fixed; passing model name + collection name now always honors collection name
  * fixed; setting virtual field to an empty object #1154
  * fixed; subclassed MongooseErrors exposure, now available in mongoose.Error.xxxx
  * fixed; model.remove() ignoring callback when executed twice [daeq](https://github.com/daeq) #1210
  * docs; add collection option to schema api docs #1222
  * docs; NOTE about db safe options
  * docs; add post hooks docs
  * docs; connection string options
  * docs; middleware is not executed with Model.remove #1241
  * docs; {g,s}etter introspection #777
  * docs; update validation docs
  * docs; add link to plugins page
  * docs; clarify error returned by unique indexes #1225
  * docs; more detail about disabling autoIndex behavior
  * docs; add homepage section to package (npm docs mongoose)
  * docs; more detail around collection name pluralization #1193
  * website; add .important css
  * website; update models page
  * website; update getting started
  * website; update quick start



Added
=============

CastErrors now include the path containing the bad value.

   Movies.findById("", function (err) {
     console.log(err)        // Cast to ObjectId failed for value "" at path "_id"
     console.log(err.path) // _id
   })
  

Mongoose now supports the full MongoDB connection string spec ( http://www.mongodb.org/display/DOCS/Connections ). Among other things, this allows us to now pass many driver options in the connection string instead of through a separate options object.

   // old
   mongoose.connect('mongodb://user:pwd@localhost:12345/dbname', { db: { w: 1, wtimeoutMS: 2000 }})
   // new
   mongoose.connect('mongodb://user:pwd@localhost:12345/dbname?w=1&wtimeoutMS=2000')


There is now a post validate event to make things more consistent between init, validate, save, and remove. All four of these "post" events also now receive the document on which the event was fired. Previously post init did not receive the document.

   schema.post('remove', function (doc) {
      console.log('this was removed:', doc);
   })


Schemas now have a "get" method to retrieve option values. Previously they were only accessible through Schema#set(key).

Versioning errors are now instanceof mongoose.Error.VersionError, which is still instanceof Error. This makes for more foolproof detection of these errors versus just checking the error message string.

   doc.save(function (err) {
     // old
     if ('No matching document found.' == err.message) ...
     // new
     if (err instanceof VersionError) ...
   })



Changed / Fixed
=============


  * fixed; do not clobber user specified driver writeConcern #1227

Schemas no longer have their "safe" option set by default, the value is now set at the connection level. This causes no behavior change other than now allowing us to pass writeConcern options when connecting and having them honored instead of being overwritten by the schemas option. We may continue to set our safe options at the schema level as before.


  * fixed; throw error when user attempts to overwrite a model

Previously, if we attempted to overwrite a model by passing the same model name with a new schema to mongoose.model or connection.model, the previously compiled model would be returned, and the programming error would be swallowed. Attempting to overwrite a previously compiled model is now properly treated as an error.


  * fixed; connection.model only caches on connection #1209

Previously, calling connection.model with a new model name and schema would compile the model and cache it globally (accessible to mongoose.model). This caused problems when users required different models on different connections with the same model name. Models compiled for a given connection are now only cached on that connection, not globally.

   mongoose.model('A', schemaA);
   var db = mongoose.createConnection(..);
   var model = db.model('A', schemaB); 
   // old behavior would return model compiled from schemaA
   // new behavior in 3.5.0 returns a new model compiled from schemaB and cached on connection only


  * fixed; passing model name + collection name now always honors collection name

Previously, when passing just the name of a precompiled model and a collection name it was implied that a model would be returned that utilized the collection name. This feature was broken, the model was being returned from the cache with no changes made for the collection name. This is now fixed. A subclassed, one-off (non-cached) model that honors the collection name is now returned.


  * fixed; setting virtual field to an empty object #1154

Previously, virtual setters were not properly triggered when set to an empty object. Now they are.

   schema.virtual('fullname').set(function (val) {
     console.log(val) // {}
   })
   ...
   doc.fullname = {};


  * fixed; model.remove() ignoring callback when executed twice [daeq](https://github.com/daeq) #1210


  * fixed/reorganized; subclassed MongooseErrors exposure, now available in mongoose.Error.xxxx

All mongoose custom error types are now accessible through mongoose.Error.xxxx. mongoose.Error is the class from which all mongoose error subclasses are derived.



Resolved issues
=============




New Bugs
========

Please report any issues if they do not already exist:
https://github.com/learnboost/mongoose/issues/new



Thank you,


--
Aaron



ben

unread,
Dec 11, 2012, 1:30:23 PM12/11/12
to mongoo...@googlegroups.com
Thanks for the hard work :D





--
--
http://mongoosejs.com - docs
http://plugins.mongoosejs.com - plugins search
http://github.com/learnboost/mongoose - source code
 
You received this message because you are subscribed to the Google
Groups "Mongoose Node.JS ORM" group.
To post to this group, send email to mongoo...@googlegroups.com
To unsubscribe from this group, send email to
mongoose-orm...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/mongoose-orm?hl=en
 
 

Message has been deleted

David Boon

unread,
Dec 11, 2012, 3:12:41 PM12/11/12
to mongoo...@googlegroups.com
Hi Aaron, awesome thanks for the update!

I just tried out the new version and am seeing some odd behavior with "Model.findOne()".  The "doc" argument in the callback function is null.  eg:

Model.findOne({'email': 'some email address'}, function(err, doc) {
   at this point doc is null, even thought this same query works fine in mongo shell....
});

The I was running 3.2.1, and just upgraded to 3.5.0.  I only made one other change and that was just to the way our connection is made, converted to host:port/db string.

Aaron Heckmann

unread,
Dec 11, 2012, 3:25:45 PM12/11/12
to mongoo...@googlegroups.com
Hi David, if you can track down a failing test case please open an issue here: https://github.com/LearnBoost/mongoose/issues/new


--
--
http://mongoosejs.com - docs
http://plugins.mongoosejs.com - plugins search
http://github.com/learnboost/mongoose - source code
 
You received this message because you are subscribed to the Google
Groups "Mongoose Node.JS ORM" group.
To post to this group, send email to mongoo...@googlegroups.com
To unsubscribe from this group, send email to
mongoose-orm...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/mongoose-orm?hl=en
 
 

David Boon

unread,
Dec 11, 2012, 3:43:08 PM12/11/12
to mongoo...@googlegroups.com
Thanks, it was my issue, I mangled the connect string when changing from the "options based" to the connect string based.

-Dave

Aaron Heckmann

unread,
Dec 11, 2012, 4:37:19 PM12/11/12
to mongoo...@googlegroups.com
To clarify, options objects are still supported. It's just that we now support the full connection string spec as well.
Reply all
Reply to author
Forward
0 new messages