• 로그인
  • 장바구니에 상품이 없습니다.

home2 게시판 Node.js, Express 게시판 nodejs 구현.. 이정도면 기초중에 기초일까요?

nodejs 구현.. 이정도면 기초중에 기초일까요?

1 글 보임 - 1 에서 1 까지 (총 1 중에서)
  • 글쓴이
  • #140928

    효진
    참가자
     KakaoTalk_20250806_104640946
    이렇게 만들고
    
    
    import Employee from "../Model/employee.js";
    import { db } from "../data/database.js";
    const employeeController = {};
    employeeController.makeOne = async (req, res) => {
        const { fullName, city, position, employed } = req.body;
        return db.execute(
          'INSERT INTO new_table (id, fullName, city, position, employed) VALUES (?,?, ?, ?, ?)',
          [fullName, city, position, employed]
        ).then((result)=> {
           res.json({ status: "success", data: result });
        })
      }
    // READ ALL
    employeeController.getAll = async (req, res) => {
      return db.execute('SELECT id, fullName, position, city, employed FROM new_table ORDER BY fullName')
      .then(result => {
          res.json({ status: "success", data: result[0] });
      }
      )  
    };
    // UPDATE
    employeeController.updateOne = async (req, res) => {
      const { id } = req.params;
      const { city, position, employed } = req.body;
      return db.execute('UPDATE new_table SET city=?, position=?, employed=? WHERE id=?',[city, position, employed, id])
      .then(()=> res.json({status:"success"}))
    };
    나름 깔끔히 만들겠다고 구현하고 있는중인데..
    이정도는 기초인건지 궁금합니다..
    
1 글 보임 - 1 에서 1 까지 (총 1 중에서)
  • 답변은 로그인 후 가능합니다.

About

현재 월 700명 신규수강중입니다.

  (09:00~20:00) 빠른 상담은 카톡 플러스친구 코딩애플 (링크)
  admin@codingapple.com
  이용약관, 개인정보처리방침
ⓒ Codingapple, 강의 예제, 영상 복제 금지
top

© Codingapple, All rights reserved. 슈퍼로켓 에듀케이션 / 서울특별시 강동구 고덕로 19길 30 / 사업자등록번호 : 212-26-14752 온라인 교육학원업 / 통신판매업신고번호 : 제 2017-서울강동-0002 호 / 개인정보관리자 : 박종흠