-
Notifications
You must be signed in to change notification settings - Fork 22
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
Does this still work? #4
Comments
@OKNoah What is the value of url in your example? |
@romanmt That's shorthand for |
I'm using node 4.2.4 and mongoose 4.4.1 (however I know I've used this project with earlier versions of both). The case you describe above is covered in the following test.
I ran this test and it passes. Please take a look at the test file to see if there's anything you might be missing. If you're still having trouble post more of your controller method and model so I can try to reproduce. |
I was experiencing the same error, I think, in this except from a document save method in my project: MetaTag.findOrCreate({tagName:tag}, {sources:[self.source]}, function(err,tagrecord,created){
if(err){
return next(err);
}
MetaTag.update({_id:tagrecord._id},{'$addToSet': {sources: self.source}});
tagrecord.myTags.forEach(function(tag){ newtags[tag]=1 });
return next();
}); The symptom was that when I would call The problem as I later identified was that I had done a refactor and moved some stuff out to a separate init function. My call to I think an improvement would be to detect this condition and call the callback with an error argument indicating that there was no available connection to make the query. It's kind of an obvious thing to check for when debugging, but it's nice when the library helps us when we're stupid. (Sorry about the double comment and delete. I was logged in with the wrong account.) (Also, just for your info, I started out by using mongoose-findorcreate which I found on npm. His is a fork of yours, but has had no updates in a while, and has no issue tracker to report issues. I found supergoose when I noticed that his was a fork. His has more downloads per month, but you have an issue tracker, so I think there is someone listening when I want to comment. Thanks for listening!) |
@mnebuerquo Thanks for the comment. I'm glad you were able to find a solution. You're suggestion is valid. I'd like for this library to be more robust. I'll be away for the next week so It will be a while before I can implement the missing connection error handling. However if you would like to implement it before then, feel free. Pull requests are always welcomed, and I'll be sure to add you to the contributors list. |
@mnebuerquo thanks for pointing this out. I was also doing the same and always got the error as below
When I tried to include console.log on user model and the db-helper(this is the file that initiates connection to mongodb), i found that user model was created first and then the connection was open. Is there any way I can delay creation of user model until the connection is established? |
hey all, I know this issue was 7 years ago but does this npm package still work? |
Using mongoose version
4.3.7
and node4.2.4
, this does not seem to work at all. Gives no errors either.Model:
Controller:
The text was updated successfully, but these errors were encountered: