balderdashy/waterline — pull request #310 by glenselle (2014-03-10 02:12:31+00:00)
Title: Unused variable insertCollection

I kept getting an error about insertCollection being null. When I looked into it, I noticed `insertCollection` was set to `null` and never set to anything else in this function. As a result, it wasn't properly throwing an error when it should have because it kept getting stuck on this `null` property.

To be specific, here's what I kept getting:

`/Users/glenselle/.nvm/v0.10.25/lib/node_modules/sails/node_modules/waterline/lib/waterline/model/lib/associationMethods/add.js:162
collection: insertCollection.identity,
^
TypeError: Cannot read property 'identity' of null
at Add.createNewRecord (/Users/glenselle/.nvm/v0.10.25/lib/node_modules/sails/node_modules/waterline/lib/waterline/model/lib/associationMethods/add.js:162:37)
at module.exports (/Users/glenselle/.nvm/v0.10.25/lib/node_modules/sails/node_modules/waterline/lib/waterline/utils/usageError.js:7:17)
at bound.module.exports.createEach (/Users/glenselle/.nvm/v0.10.25/lib/node_modules/sails/node_modules/waterline/lib/waterline/query/aggregate.js:47:23)
at bound [as createEach] (/Users/glenselle/.nvm/v0.10.25/lib/node_modules/sails/node_modules/lodash/dist/lodash.js:729:21)
at bound.module.exports.create (/Users/glenselle/.nvm/v0.10.25/lib/node_modules/sails/node_modules/waterline/lib/waterline/query/dql.js:54:19)
at bound [as create] (/Users/glenselle/.nvm/v0.10.25/lib/node_modules/sails/node_modules/lodash/dist/lodash.js:729:21)
at Add.createNewRecord (/Users/glenselle/.nvm/v0.10.25/lib/node_modules/sails/node_modules/waterline/lib/waterline/model/lib/associationMethods/add.js:157:14)
at Add.createAssociations (/Users/glenselle/.nvm/v0.10.25/lib/node_modules/sails/node_modules/waterline/lib/waterline/model/lib/associationMethods/add.js:125:19)
at replenish (/Users/glenselle/.nvm/v0.10.25/lib/node_modules/sails/node_modules/async/lib/async.js:179:21)
at _eachLimit (/Users/glenselle/.nvm/v0.10.25/lib/node_modules/sails/node_modules/async/lib/async.js:196:15)`

But after changing `insertCollection` to `collection` and `callback()` to `cb()` (https://github.com/balderdashy/waterline/pull/309), I got an error I should have gotten all along, but wasn't because it kept failing in these two places:

`err: 'duplicate key value violates unique constraint "message_pkey"'`