ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • 230204 TIL
    TIL 2023. 2. 4. 23:31

    라우터에서 파라미터 여러개 받을 때 &으로 연결

     

    url창에서 쏠떄는 1&1 

    이런식으로 쏴주면 댄닷

     


     

    오늘은 프로젝트 DB구조 바꾸고 나서

     

    sequelize belongsto 안쓰고 바로 join을 쓰기 위해

     

    그냥 로우쿼리로 적었다.

     

        async getAllOrdersInProgress(userId){
    
            try{
                const query =   `
                    select * from ` + '`order`' + ` o
                    inner join orderDetail od on o.orderId = od.orderId
                    where o.userId = ? and od.orderStatus < 3
                    group by o.orderId
                    order by o.orderId desc
                `;
    
                const orders = await sequelize.query(query, {
                    type: QueryTypes.SELECT,
                    replacements: [userId]
                });
                
                return orders;
    
            } catch (err) {
    
                console.log(err);
            }
        }

    대충 이런식으로

     

     


     

    sequelize 쓸 때 DB구조 수동으로 바꾸고 나서는 꼭 sequelize-auto 돌려주자

    'TIL' 카테고리의 다른 글

    230208 TIL  (0) 2023.02.08
    230206 TIL  (0) 2023.02.07
    230203 TIL  (0) 2023.02.03
    230202 TIL  (0) 2023.02.02
    230122 TIL  (0) 2023.01.22
Designed by Tistory.