실습 프로젝트 총결산

4810 단어 express
squelize curd 작업
찾기:
 async getContactUsInfo (info) {
     
        let {
      language } = info
        return await ContactUsModel.findOne({
     
            where: {
     
                language,
                status: 1,
                deleted_at: null
            },
            attributes: ['id','phone','email','address','cover']
        })
    }

저장(없으면 생성, 있으면 업데이트)
async saveContactUsInfo (info) {
     
        let {
      setting_id, phone, email, address, cover, language, status = 1, created_by } = info
        return await ContactUsModel.upsert({
     
            id: setting_id,
            phone,
            email,
            address,
            cover,
            language,
            status,
            created_by,
            updated_at: CommonUtils.getCurrentDateTime()
        },{
     
            validate: true,
            fields: ['phone','email','address','cover','updated_at']
        })
    }

좋은 웹페이지 즐겨찾기