sequelize findone where code example
Example 1: sequelize find one
const project = await Project.findOne({ where: { title: 'My Title' } });
if (project === null) {
console.log('Not found!');
} else {
console.log(project instanceof Project);
console.log(project.title);
}
Example 2: sequelize get where
const Tokens = db.define('tokens', {
guid: {
type: sequelize.STRING
}
});
Tokens.findAll({
where: { guid: 'guid12345' }
}).then(tokens => {
console.log(tokens);
}).catch(err => console.log('error: ' + err));;