2022.07.20 - TIL [ 외래키와 $변수 ]

Seong Hyeon Kim·2022년 7월 19일
0

TIL

목록 보기
25/31
post-thumbnail

let autoSchedules = await user_schedule.findAll({
        where: {
          userid: user.id,
          '$Schedule.postingId$': { [Op.ne]: null },
          [Op.or]: [
            { '$Schedule.title$': { [Op.like]: '%' + keyword + '%' } },
            { memo: { [Op.like]: '%' + keyword + '%' } },
            { '$Schedule.place$': { [Op.like]: '%' + keyword + '%' } },
            { '$Schedule.companyName$': { [Op.like]: '%' + keyword + '%' } },
          ],
        },
        include: [
          {
            model: Schedule,
            attributes: attributesOption(),
          },
        ],
      });

검색창 기능을 만들기 위해서 작성하는 코드의 일부분인데,

자세히 보면

profile
삽질도 100번 하면 요령이 생긴다. 부족한 건 경험으로 채우는 백엔드 개발자

0개의 댓글