Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var Sequelize = require("sequelize").Sequelize;
- var sequelize = new Sequelize('andrewfox_main', 'andrewfox_dev', 'seurat', {
- host: "mysql.andrewfoxmusics.com"
- });
- User = sequelize.define('User', {
- name: { type: Sequelize.STRING, allowNull: false},
- email: { type: Sequelize.STRING, allowNull: false},
- password: { type: Sequelize.STRING, allowNull: false},
- isAdmin: { type: Sequelize.BOOLEAN, allowNull: false, default: false }
- });
- sequelize.sync(); // Syncs table changes if there are any. If the table doesn't exist, it creates it.
- gabe = new User({name:'Gabe',email:'gabe@advizo.com',password:null});
- try{
- gabe.save(); // Won't work. password cannot be null.
- }
- catch(err){
- console.log(err.message); // THROWS 'The object is not valid! Invalid fields: email'
- }
- gabe.password = 'test1234';
- gabe.save(); // NO ERROR
Add Comment
Please, Sign In to add comment