テーブルへデータの追加、検索
table: users
column: username, password, is_active,
const Op = Sequelize.Op; const User = sequelize.define('user', { id: { type: Sequelize.INTEGER, primaryKey: true, autoIncrement: true }, username: { type: Sequelize.STRING, allowNull: false, }, password: { type: Sequelize.STRING, allowNull: false, }, isActive: { field: 'is_active', type: Sequelize.BOOLEAN, allowNull: false, defaultValue: true, }, },{ timestamps: true, underscored: true, }); console.log('It worked'); var user = User.create({ username: "test", password: "test", isActive: true, }).then(() => { User.findAll({ where: { id: { [Op.gt]: 0 } } }).then(results => { for(let i = 0; i < results.length; i++){ let result = results[i]; console.log(result.id); } }).catch(error => { console.log("[ERROR]" + error); }); }).catch(error => { console.log(error); }); This post is licensed under CC BY 4.0 by the author.