ภาคต่อ常用操作การสาธิต
链接
var sequelize = require ('sequelize'); var sequelize = new sequelize ('nodejs', 'root', '', {host: '127.0.0.1', พอร์ต: '3306', ภาษาถิ่น: 'mysql'});查询
task.findall ({limit: 10, อายุ: {gt: 3}, คำสั่ง: 'id asc'}, {raw: true, การบันทึก: จริง, ธรรมดา: false}). on ('ความสำเร็จ', ฟังก์ชั่น (res) {console.log (res);})统计
task.count ({โดยที่: {title: 'test_title_1'}}, {การบันทึก: false}). on ('ความสำเร็จ', ฟังก์ชั่น (i) {console.log (i);}). on ('ความล้มเหลว', ฟังก์ชั่น (err) {console.log (err);});最大或最小
task.max ('id'). on ('ความสำเร็จ', ฟังก์ชั่น (สูงสุด) {console.log (สูงสุด);}). on ('ความล้มเหลว', ฟังก์ชั่น (err) {console.log (err);});插入
task.build ({title: 'test_title_3', 'คำอธิบาย': 'test_description_3'}). บันทึก (). on ('ความสำเร็จ', ฟังก์ชั่น (msg) {console.log (msg);}). on ('ความล้มเหลว' 'test_description_4'}). on ('ความสำเร็จ', ฟังก์ชั่น (msg) {console.log (msg);}). on ('ความล้มเหลว', ฟังก์ชั่น (err) {console.log (err);});修改
task.update ({คำอธิบาย: 'test_description_2000'}, {id: '2'}). on ('ความสำเร็จ', ฟังก์ชั่น (msg) {console.log (msg);}). on ('ล้มเหลว', ฟังก์ชั่น (err) {console.log (err);});删除
task.destroy ({id: '4'}). on ('ความสำเร็จ', ฟังก์ชั่น (msg) {console.log (msg);}) on ('ความล้มเหลว', ฟังก์ชั่น (err) {console.log (err);});感谢阅读, 希望能帮助到大家, 谢谢大家对本站的支持!