Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Cannot call method 'insert' of undefined #76

Closed
dalgard opened this issue Dec 11, 2014 · 9 comments
Closed

TypeError: Cannot call method 'insert' of undefined #76

dalgard opened this issue Dec 11, 2014 · 9 comments

Comments

@dalgard
Copy link

dalgard commented Dec 11, 2014

It seems like the collection-hooks package somehow isn't properly applied. I've removed all other 3rd party packages from the project and the only active code is this:

Projects = new Mongo.Collection("projects");

Projects.before.insert(function () { ... });

What gives? I've recently upgraded Meteor and packages to newest versions. How to troubleshoot? Thanks.

@fusepilot
Copy link

Had the same problem. Not ideal but specifing the current version fixed it for me.

matb33:collection-hooks@0.7.6

@matb33
Copy link
Collaborator

matb33 commented Dec 14, 2014

Possibly due to using api.versionsFrom of 0.9. Not sure but that's where I'll start. Will I be able to repro this easily? Just in case, are you willing to prepare me a quick project that exhibits the issue?

@eportico
Copy link

I have the same problem with Meteor 1.0.1

@dalgard
Copy link
Author

dalgard commented Dec 15, 2014

Thanks for posting back. Your comments sent me in the right direction – when I create a new project, version 0.7.6 is used automatically and the problem doesn't arise.

The reason why the wrong version is used, I'm pretty sure, is that I have added sewdn:collection-behaviours which has these lines in web.browser.json:

"uses": [
  {
    "package": "matb33:collection-hooks",
    "constraint": "0.7.3"
  }
]

@dalgard
Copy link
Author

dalgard commented Dec 15, 2014

Meteor tells me all my packages are updated, but when I browse the code for sewdn:collection-behaviours on GitHub, I note that the package.js file of that project does refer to the correct version of matb33:collection-hooks, i.e. the most recent.

I wonder whether the issues all stem from packages not being up to date on Atmosphere?

@dalgard
Copy link
Author

dalgard commented Dec 16, 2014

sewdn:collection-behaviors exists in version 0.2.0 on GitHub as opposed to 0.1.5 on Atmosphere, and 0.2.0 has the most recent version of matb33:collection-hooks as its constraint, so there's no problem.

I'm now using the sewdn:collection-behaviors package by cloning the git repo into my packages/ folder which is working okay (git clone https://github.com/Sewdn/meteor-collection-behaviours.git).

Atmosphere still has some way to go, in my opinion, such as closer integration with GitHub...

@dalgard dalgard closed this as completed Dec 16, 2014
@ibussieres
Copy link

This might sound stupid, but for me, it was simply because I am using package file structure and hadn't added matb33:collection-hooks to package.js dependencies.

@nicejwjin
Copy link

I don't think this question is matched perfectly but argument of '.before.findOne (userId, selector, options) -> ' functions are all undefined, {} something like that even the findOne's result was fine. I can't catch anything for these stupid situations..

@capi1O
Copy link

capi1O commented Feb 9, 2019

Ran into this issue using meteor 1.8.

Tried to use version 0.9-rc4 (from the github repo) but got the same error. Any clue ?

After siwtching to branch meteor-1.6.1 I now have another error instead :

Error: First argument to new Mongo.Collection must be a string or null

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants