NCNU-Scholarship/models/todo.js
2024-05-29 19:03:32 +08:00

24 lines
645 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// // 引入 db也就是 connection
// const db = require('../db')
// const todoModel = {
// // 這裡要用 callback 來拿取資料
// getAll: (cb) => {
// db.query(
// 'SELECT * FROM todos', (err, results) => {
// if (err) return cb(err);
// // cb: 第一個參數為是否有錯誤,沒有的話就是 null第二個才是結果
// cb(null, results)
// });
// },
// get: (id, cb) => {
// db.query(
// 'SELECT * FROM todos WHERE id = ?', [id], (err, results) => {
// if (err) return cb(err);
// cb(null, results)
// });
// }
// }
// module.exports = todoModel