浅谈Node.js ORM框架Sequlize之表间关系

2020-06-17 06:38:56易采站长站整理

}
}

},
email: {
type: Sequelize.STRING,
validate: {
isEmail: true,
}
},
userpicture: Sequelize.STRING,
}, {
freezeTableName: true,
});
//
//同步User1模型
// User1.sync().then((log) => {
// log = JSON.stringify(log);
// console.log('==========================');
// console.log('User1表数据同步成功' + log);
// console.log('==========================');
// }).catch((error) => {
// console.log('==========================');
// console.log('User1模型与表数据同步失败' + error);
// console.log('==========================');
// });

function addUser1(userInfo) {
User1.create({
name: userInfo.name,
age:userInfo.age,
email:userInfo.email,
}).then((log) => {
log = JSON.stringify(log);
console.log('==========================');
console.log('添加的数据为' + log);
console.log('==========================');

}).catch((error) => {
console.log('==========================');
console.log('添加数据失败' + error);
console.log('==========================');

});
}
const userInfo={
name:'郭东生',
//age:0.1,//Validation error: 年龄必须是整数!
age:22,
email:'7758@qq.com',
//email:'7758',//Validation error: Validation isEmail on email failed
}
addUser1(userInfo);

以上这篇浅谈Node.js ORM框架Sequlize之表间关系就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持软件开发网。