Created
July 2, 2020 14:01
-
-
Save steebchen/b3d4b8fb0b01ee5bbd936e1ad71cef1f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## example | |
```js | |
const user = await prisma.user.update({ | |
where: { | |
email: '[email protected]', | |
}, | |
data: { | |
posts: { | |
update: [ | |
// a | |
{ | |
data: { published: true }, | |
where: { id: 32 }, | |
}, | |
// b | |
{ | |
data: { published: true }, | |
where: { id: 23 }, | |
}, | |
], | |
}, | |
}, | |
}) | |
``` | |
with specific go client syntax: | |
```go | |
result, err := client.User.FindOne( | |
db.User.Email.Equals("[email protected]"), | |
).Update( | |
db.User.Posts.Update( | |
// a | |
User.Posts.FindOne( | |
User.ID.Equals(32), | |
).Update( | |
User.Published.Set(true), | |
), | |
// b | |
User.Posts.FindOne( | |
User.ID.Equals(32), | |
).Update( | |
User.Published.Set(true), | |
), | |
), | |
) | |
``` | |
with inputTypes: | |
```go | |
result, err := client.User.UpdateOne( | |
db.UserWhereUniqueInput( | |
db.UserWhereUniqueInputEmail("[email protected]"), | |
), | |
// data | |
db.UserUpdateInput( | |
// posts | |
db.PostUpdateManyWithoutAuthorInput( | |
// update (arr) | |
db.PostUpdateWithWhereUniqueWithoutAuthorInput( | |
db.UserUpdateWithWhereUniqueInput( | |
db.PostWhereUniqueInput( | |
db.PostWhereUniqueInputID(32), | |
), | |
db.PostUpdateWithoutAuthorDataInput( | |
db.PostUpdateWithoutAuthorDataInputPublished(true), | |
), | |
), | |
), | |
db.PostUpdateWithWhereUniqueWithoutAuthorInput( | |
db.UserUpdateWithWhereUniqueInput( | |
db.PostWhereUniqueInput( | |
db.PostWhereUniqueInputID(23), | |
), | |
db.PostUpdateWithoutAuthorDataInput( | |
db.PostUpdateWithoutAuthorDataInputPublished(true), | |
), | |
), | |
), | |
), | |
), | |
) | |
``` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment