undefined or `''`?
# orm-help
g
undefined or
''
?
a
Copy code
mutation {
  updateEmployee(
    data: {
      title: ""
    }
    where: {
      title: null
    }
  ) {
    id
    name
  }
}
w
Can’t find again where I found this once, but using a `where: { field: null }`should be the valid way of doing this
a
Copy code
"Argument 'where' expected type 'EmployeeWhereUniqueInput!' but got: {title: null}. Reason: 'title' Field 'title' is not defined in the input type 'EmployeeWhereUniqueInput'. (line 2, column 44):\n  updateEmployee(data: {title: \"\"}, where: {title: null}) {\n                                           ^\n (line 2, column 45):\n  updateEmployee(data: {title: \"\"}, where: {title: null}) {\n
Apparently it works when I try the
id
field, but that seems kinda pointless 😛
w
Ah right, that’s because you first need to put your field as not required, script your migration using the above mutation, and then put it as required once all your nodes have data
a
Heh, that's exactly what I tried to do.
w
😞
a
I first tried to deploy the
String!
variant, but then prisma let me know that constraints would be violated. Ok fine..I wanted to try the mutation.. and here we are 😛
w
`Reason: 'title' Field 'title' is not defined in the input type 'EmployeeWhereUniqueInput'`: Looks like your
title
field wasn’t properly deployed to your api
n
is
title
a unique property on the
Employee
type?
a
No it isn't @nilan
n
Then you can't use it in the
where
selection for single nodes.
Maybe you meant to run
updateManyEmployees
?
a
Aha, I guess so then. Since there was a where clause in the
updateEmployee
, I kinda expected it to hit all rows in the table.
n
updateEmployee
updates a single node, selected by a unique argument specified in
where
updateManyEmployee
updates an arbitrary number of nodes, selected by arbitrary conditions specified in
where
w
Ahhhh, of course, silly me! Good catch @nilan!
👍 1
a
I don't quite understand why there is a distinction between updating one node and updating many nodes, but oh well. This is exactly what I needed!
n
There are different reasons 🙂