Skip to content

Commit

Permalink
docuemnt set operation
Browse files Browse the repository at this point in the history
  • Loading branch information
nikolasburk committed Nov 29, 2019
1 parent 0a31e8a commit 9227ce5
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions docs/photon/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Photon is a type-safe database client auto-generated based on your [data model d
- [Field selection](#field-selection)
- [Relations](#relations)
- [Raw databases access](#raw-database-access)
- [Scalar lists](#scalar-lists)
- [Bring your own ID](#bring-your-own-id)
- [API Reference](#api-reference)
- [Filtering](#filtering)
Expand Down Expand Up @@ -187,6 +188,38 @@ Note that Photon.js will throw an error if you're trying to create/update a reco

Coming soon.

## Scalar lists

Photon.js provides a dedicated API for (re)setting _scalar lists_ using a `set` field inside the `data` argument when creating or updating a [Prisma model](../data-modeling.md#models), for example:

```groovy
model User {
id Int @id
coinFlips Boolean[]
}
```

When creating or updating a `User` record, you can create a new list or replace the current one with a new list like so:

```ts
await photon.users.create({
data: {
coinFlips: {
set: [true, false]
}
}
})

await photon.users.update({
where: { id: 42 ,}
data: {
coinFlips: {
set: [true, false]
}
}
})
```

## API reference

For simplicity, we're assuming the `User` model from above as foundation for the generated code.
Expand Down

0 comments on commit 9227ce5

Please sign in to comment.