Answers for "findall where column sequelize"

3

sequelize get where

// Example
const Tokens = db.define('tokens', {
    guid: {
        type: sequelize.STRING
    }
});
// The basics of Sequelize Get Where
Tokens.findAll({
        where: { guid: 'guid12345' }
    }).then(tokens => {
        console.log(tokens);
    }).catch(err => console.log('error: ' + err));;
// is equal to >> SELECT * FROM Tokens WHERE guid = 'guid12345'
Posted by: Guest on January-25-2021
0

sequelize find query to fetch specific columns

Model.findAll({
	where: { RoleId: 2 },
  	attributes: { include: ['Name', 'Age'] }
});

Model.findAll({
  	where: { RoleId: 2 },
  	attributes: { exclude: ['Gender'] }
});
Posted by: Guest on April-22-2022

Code answers related to "Javascript"

Browse Popular Code Answers by Language