findOrCreate hangs, if only one connection is available
See original GitHub issueIn the example the maximum amount of conections is set to 1.
findOrCreate does not return (or maybe it will at the idle time…)
If “max:2”, then it works (giving an exception due to unique violation.
var S = require('sequelize');
var sequelize = new S('seq_test', 'passwd', '', {
host: 'localhost',
dialect: 'postgres',
pool: { max: 1,
min: 0, idle: 10000, },
define: { },
});
var User = sequelize.define('User', {
name: { type: S.STRING(50), allowNull: true, unique: true},
pass: { type: S.STRING(50), allowNull: true},
});
sequelize.sync()
.then(function (){
User.create({ name: 'A', pass: 'A' })
.then(function (){
User.findOrCreate({
defaults: { name: 'A', pass: 'A' },
where: { name: 'B' }
})
.catch(function (e){
console.log('ERR', e);
})
.then(function (){
console.log('DONE');
sequelize.close();
});
});
});
Issue Analytics
- State:
- Created 8 years ago
- Comments:12 (9 by maintainers)
Top Results From Across the Web
get .findOrCreate() error - mysql - Stack Overflow
According to the link you shared, this code works, but it's not the recommended way to work with methods that return multiple arguments....
Read more >Lucid Models - AdonisJs
findOrCreate (whereAttributes, values). Find a record, if not found a new record will be created and returned back on the fly. const ...
Read more >Imac hangs on shut down - Apple Community - Apple Discussions
Also check your print que to see if there are any hung print jobs. Show more Less ... If you have only one...
Read more >After Applying CPU, Java Patches, WLS Admin Server Hangs ...
Tried restoring from a complete tar of the top directory from prior the patches application but it still fails, and the log error...
Read more >.findOrCreate() - Sails.js
findOne() , so if more than one record in the database matches the provided criteria, there will be an error explaining so. Is...
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
“not stale”
not stale