If attaching friendly slugs to Meteor.users, the following error is thrown when attempting to sign in:
Exception while invoking method 'login' MongoError: '$set' is empty. You must specify a field like so: {$mod: {: ...}}
at Object.Future.wait (/home/action/.parts/packages/meteor/1.0/packages/meteor-tool/.1.1.3.bx32hb++os.linux.x86_64+web.browser+web.cordova/mt
-os.linux.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:398:15)
What is happening is that you can't send an empty $set for the login/logoff update calls that Meteor makes to the DB, so when modifying $set with collection-hooks for users, $set either needs to have something in it, or be undefined. The slug code initializes this like so:
modifier.$set = modifier.$set || {}
causing an empty $set to be sent to this update call.
This is an issue I ran into before with collection-hooks and the Meteor.users collection, so I can confirm that this is an issue that will happen. In my case, the problem was easy to fix; I just didn't initialize modifier.$set and skipped my hook if it was undefined. But I had a specific hook setup for my users collection, and not a generic implementation like this package accomplished.
I don't know what the solution could be for this package, though; I don't know how you would be able to check what collection you're working with at runtime and handle it appropriately.
Perhaps a simple solution would be to check if modifers.$set is empty at the very end of the hook; if it is, set it to undefined.
If attaching friendly slugs to Meteor.users, the following error is thrown when attempting to sign in:
Exception while invoking method 'login' MongoError: '$set' is empty. You must specify a field like so: {$mod: {: ...}}
at Object.Future.wait (/home/action/.parts/packages/meteor/1.0/packages/meteor-tool/.1.1.3.bx32hb++os.linux.x86_64+web.browser+web.cordova/mt -os.linux.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:398:15)
What is happening is that you can't send an empty $set for the login/logoff update calls that Meteor makes to the DB, so when modifying $set with collection-hooks for users, $set either needs to have something in it, or be undefined. The slug code initializes this like so:
modifier.$set = modifier.$set || {}
causing an empty $set to be sent to this update call.
This is an issue I ran into before with collection-hooks and the Meteor.users collection, so I can confirm that this is an issue that will happen. In my case, the problem was easy to fix; I just didn't initialize modifier.$set and skipped my hook if it was undefined. But I had a specific hook setup for my users collection, and not a generic implementation like this package accomplished.
I don't know what the solution could be for this package, though; I don't know how you would be able to check what collection you're working with at runtime and handle it appropriately.
Perhaps a simple solution would be to check if modifers.$set is empty at the very end of the hook; if it is, set it to undefined.