Saving issues
See original GitHub issueI probably misundestood something about your module, because this kind of code
'use strict';
var User = require('../models/user.js');
/**
* Make any changes you need to make to the database here
*/
exports.up = function up(done) {
User = this('User');
var user = new User({
username: "foo"
});
user.save()
.then(function(response) {
console.log(response);
done();
})
.catch(function(err) {
console.log(err);
done(err);
});
};
seems to block on the call to mongoose save. Did I miss something about how thinks should be done ?
Issue Analytics
- State:
- Created 7 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
21 Money Saving Challenges to Try in 2022 - Inspired Budget
21 Money-Saving Challenges To Try in 2022 · 1. No-Spend Challenge · 2. 52-Week Money Challenge Backwards · 3. 8-Week Vacation Savings Plan...
Read more >18 Money-Saving Challenges To Save More Money!
18 money saving challenges to try today · 1. The 6 month savings challenge · 2. 30 days to master your spending challenge...
Read more >8 Savings Challenges To Try This Year – Forbes Advisor
8 Savings Challenges To Help You Reach Your Money Goals This Year · 1. 52-Week Challenge · 2. Dollar Savings Challenge · 3....
Read more >20 Money Saving Challenges To Try Before the End of the Year
1. Save the Change Challenge · 2. The $5 Challenge · 3. Trim 1% of Your Salary Challenge · 4. The Weather Wednesday...
Read more >Shopportunist: Money-saving challenges to try in 2023
Shopportunist: Money-saving challenges to try in 2023. Looking to save more money in the new year? How about participating in a yearlong ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I’ve just run into this as well. I think it is due to commit 02e6f018ca9d71e3082b1c819c438630c7ba0b32.
Mongoose’s behavior is to hang if there is not a connection when you tell it to do something. If your model module just does the standard
User = mongoose.model('User',UserSchema)then it gets attached to the first connection for mongoose. Later on when you callsave()it is against this connection that has never been initialized (since migrate-mongoose creates and initializes its own connection.) If you add something like thisto the beginning of each migration, it’ll make sure it is connected. I don’t know if there is a better place to put such code, but this got me past this problem after struggling with it for a few hours. (I put it in the migration since I didn’t want to clutter the app’s code since the app can always assume a connection is there.)
I’m not sure what the reasoning of the prior commit was, but the docs should probably get updated to alert users because it sure is a non-obvious behavior.
This is still an issue for me. I’m using 3.2.2.
I have to do @gt6796c suggested.
Any suggestion to use the default connection instead of opening a new one?