Today, we are issuing the seventh Beta release: 2.0.0-beta.7
(short: beta.7
).
New Pagination
Prisma Client's pagination has been simplified a lot!
- Removed
first
,last
,before
,after
arguments. - Added
cursor
andtake
arguments. skip
argument unchanged.
The take
argument replaces first
and last
.
Examples
first
prisma.user.findMany({
first: 10
})
// becomes
prisma.user.findMany({
take: 10
})
last
prisma.user.findMany({
last: 10
})
// becomes
prisma.user.findMany({
take: -10
})
before
prisma.user.findMany({
before: "someid"
first: 10
})
// becomes
prisma.user.findMany({
cursor: "someid"
take: -10
skip: 1
})
after
prisma.user.findMany({
after: "someid"
first: 10
})
// becomes
prisma.user.findMany({
cursor: "someid"
take: 10
skip: 1
})
The record specified with cursor
is now included in the results, making skip: 1
necessary if you want to preserve the previous before
/ after
semantics.
This diagram illustrates how the pagination works:
cursor: 5
skip: 0 or undefined
│
│
│
▼
┌───┐┌───┐┌───┐┏━━━┓┏━━━┓┌───┐┌───┐┌───┐┌───┐┌───┐
│ 1 ││ 2 ││ 3 │┃ 4 ┃┃ 5 ┃│ 6 ││ 7 ││ 8 ││ 9 ││10 │
└───┘└───┘└───┘┗━━━┛┗━━━┛└───┘└───┘└───┘└───┘└───┘
◀────────
take: -2
cursor: 5
skip: 1
│
│
│
▼
┌───┐┌───┐┏━━━┓┏━━━┓┌───┐┌───┐┌───┐┌───┐┌───┐┌───┐
│ 1 ││ 2 │┃ 3 ┃┃ 4 ┃│ 5 ││ 6 ││ 7 ││ 8 ││ 9 ││10 │
└───┘└───┘┗━━━┛┗━━━┛└───┘└───┘└───┘└───┘└───┘└───┘
◀────────
take: -2
cursor: 5
skip: 2
│
│
│
▼
┌───┐┏━━━┓┏━━━┓┌───┐┌───┐┌───┐┌───┐┌───┐┌───┐┌───┐
│ 1 │┃ 2 ┃┃ 3 ┃│ 4 ││ 5 ││ 6 ││ 7 ││ 8 ││ 9 ││10 │
└───┘┗━━━┛┗━━━┛└───┘└───┘└───┘└───┘└───┘└───┘└───┘
◀────────
take: -2
cursor: 5
skip: 0 or undefined
│
│
│
▼
┌───┐┌───┐┌───┐┌───┐┏━━━┓┏━━━┓┏━━━┓┌───┐┌───┐┌───┐
│ 1 ││ 2 ││ 3 ││ 4 │┃ 5 ┃┃ 6 ┃┃ 7 ┃│ 8 ││ 9 ││10 │
└───┘└───┘└───┘└───┘┗━━━┛┗━━━┛┗━━━┛└───┘└───┘└───┘
──────────▶
take: 3
cursor: 5
skip: 1
│
│
│
▼
┌───┐┌───┐┌───┐┌───┐┌───┐┏━━━┓┏━━━┓┏━━━┓┌───┐┌───┐
│ 1 ││ 2 ││ 3 ││ 4 ││ 5 │┃ 6 ┃┃ 7 ┃┃ 8 ┃│ 9 ││10 │
└───┘└───┘└───┘└───┘└───┘┗━━━┛┗━━━┛┗━━━┛└───┘└───┘
──────────▶
take: 3
cursor: 5
skip: 2
│
│
│
▼
┌───┐┌───┐┌───┐┌───┐┌───┐┌───┐┏━━━┓┏━━━┓┏━━━┓┌───┐
│ 1 ││ 2 ││ 3 ││ 4 ││ 5 ││ 6 │┃ 7 ┃┃ 8 ┃┃ 9 ┃│10 │
└───┘└───┘└───┘└───┘└───┘└───┘┗━━━┛┗━━━┛┗━━━┛└───┘
──────────▶
take: 3
Auto restart on panic
The Query Engine now automatically restarts with an exponential backoff with jitter, if it exits for some reason, for example in the case of a panic. That helps a lot to make Prisma Client more resilient in production!
#2100
Introspection now recognizes @default(cuid / uuid)
If you introspect a Prisma 1 schema, the introspection now correctly recognizes cuid
or uuid
usage
#2499
Fixes and improvements
prisma
- Prisma should check for generator binaries in $PATH
- A generator provider should accept arbitrary commands
generate
does not work in folders with spaces- Restart engine on panic
- Unable to save arrays in a Json type field
findMany
with aselect
argument errors out with models with self-relations (sometimes)- [Introspection] Identify Prisma 1 Id defaults
- Prisma Client mixes up DateTimes and IDs when they are
select
ed in queries findMany
fails toselect
an enum list & a relation scalar at the same time- [Prisma Client] Duplicate identifier with models "X" and "XClient"
- Output notice about Prisma1->Prisma2 upgrade documentation and tool
- New raw functions not exported from @prisma/client
- Generated GitHub link too long
prisma-client-js
vscode
- Message: Request textDocument/definition failed with message: Schema parsing
- Show linter snippet in formatting error
- Using svg breaks markeplace publish
- Not possible to use backslash in string field
- Run CI tests every time a release gets published
- Include CLI version in startup output
- Startup output does not include binary hash any more
- Using autocompletion for
@default()
puts curcor after)
instead of inside()
- Ctrl+Space does not suggest current model for self relation
@unique @unique
- Formatter adds new lines on every format call
- Move out anything unimportant to users from README to CONTRUBUTING.md
- Update README preview image
- Improving README
- vscode plugin formatting bug
- Auto-completion for relation directive shows wrong suggestions
- Format incorrectly deletes invalid lines
- Format deletes new lines in invalid block and removes any whitespaces in the beginning
- Format moves lines on every format call in an invalid schema