实习项目总结

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']
        })
    }

你可能感兴趣的:(express)