Skip to content

Angus Townsley#135

Open
angustownsley wants to merge 7 commits intoboolean-uk:mainfrom
angustownsley:main
Open

Angus Townsley#135
angustownsley wants to merge 7 commits intoboolean-uk:mainfrom
angustownsley:main

Conversation

@angustownsley
Copy link

No description provided.

const updateCustomer = async (req, res) => {
const { name, contact } = req.body

const id = Number(req.params.id)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Treat your client as if it has an IQ of -1 and wants to murder your server by any means necessary

Comment on lines +1 to +6
const {
createMovieDb,
getAllMoviesDb,
findMovieByIdDb,
updateMovieByIdDb,
} = require('../domains/movies.js')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const db = require('../domains/movies.js')

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

d.createMovie()


res.status(201).json({ movie: updatedMovie })
} catch (e) {
if ((e.code = 'P2015')) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assignment

Comment on lines +26 to +56
if (contact) {
return await prisma.customer.update({
where: {
id: id,
},
data: {
name,
contact: {
update: {
data: { email: contact.email, phone: contact.phone },
},
},
},
include: {
contact: true,
},
})
}
},
// We add an `include` outside of the `data` object to make sure the new contact is returned in the result
// This is like doing RETURNING in SQL
include: {
contact: true
}
})

return await prisma.customer.update({
where: {
id: id,
},
data: {
name,
},
include: {
contact: true,
},
})
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const data = {
    name
}

if (contact) {
  data.contact: {
                    update: {
                        data: { email: contact.email, phone: contact.phone },
                    },
                
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants