Can I do a synchronous find()
with Sequelize? e.g.
const user = User.find({ id: 1 })
(This seems to just get a promise.)
Can I do a synchronous find()
with Sequelize? e.g.
const user = User.find({ id: 1 })
(This seems to just get a promise.)
I ended up doing this
const user = yield User.find({ id });
It seems to work as expected.
Sequelize its all based in promises , if you are facing a use case like auth , you probably want to add a layer to your application , like middleware in express , so before your application execute some action , you need to authenticate users ( auth middleware ) and then pass to the next function.
//Auth Middleware example
function(req,res,next){
User.find({id:1)
.then(function(user){
req.user = user;
next();
})
.catch(function(error){
next(error)
})
}