{"action":"closed","issue":{"url":"https://api.github.com/repos/rclai/meteor-collection-extensions/issues/6","labels_url":"https://api.github.com/repos/rclai/meteor-collection-extensions/issues/6/labels{/name}","comments_url":"https://api.github.com/repos/rclai/meteor-collection-extensions/issues/6/comments","events_url":"https://api.github.com/repos/rclai/meteor-collection-extensions/issues/6/events","html_url":"https://github.com/rclai/meteor-collection-extensions/issues/6","id":94621900,"number":6,"title":"Meteor.Collection !== Meteor.Collection.prototype.constructor","user":{"login":"vsivsi","id":428642,"avatar_url":"https://avatars.githubusercontent.com/u/428642?v=3","gravatar_id":"","url":"https://api.github.com/users/vsivsi","html_url":"https://github.com/vsivsi","followers_url":"https://api.github.com/users/vsivsi/followers","following_url":"https://api.github.com/users/vsivsi/following{/other_user}","gists_url":"https://api.github.com/users/vsivsi/gists{/gist_id}","starred_url":"https://api.github.com/users/vsivsi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vsivsi/subscriptions","organizations_url":"https://api.github.com/users/vsivsi/orgs","repos_url":"https://api.github.com/users/vsivsi/repos","events_url":"https://api.github.com/users/vsivsi/events{/privacy}","received_events_url":"https://api.github.com/users/vsivsi/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-07-13T02:16:12Z","updated_at":"2015-07-14T12:04:43Z","closed_at":"2015-07-14T12:04:43Z","body":"After loading this package, the `Meteor.Collection` object is left halfway between the old state and the extended state. Any package that extends the patched `Meteor.Collection` using prototype inheritance, such as using Coffeescript [class / extends](http://coffeescript.org/#classes) will fail to use the monkey-patched constructor.\r\n\r\nHere's the issue where I discovered this: https://github.com/vsivsi/meteor-file-sample-app/issues/2#issuecomment-120780592\r\n\r\nI'm not embarrassed to say that I'm pretty opinionated about this, and I'm going to add more sanity checks and throws to my packages to defend against other packages that misbehave when replacing Meteor provided standard system calls.\r\n\r\nIMO, the safe and sane way to extend `Mongo.Collection` is via a mechanism that supports, e.g.:\r\n\r\n```js\r\nextendedCollection = collectionExtend(Mongo.Collection, methods);\r\ncollection = new extendedCollection('foo');\r\nextraExtendedCollection = collectionExtend(extendedCollection, methods);\r\ncollection2 = new extraExtendedCollection('bar');\r\n```\r\n\r\nIf the app developer wants the \"convenience\" of setting `Mongo.Collection = extraExtendedCollection` then let that be *their* choice.\r\n"}}