Skip to content

v0.9.0

Compare
Choose a tag to compare
@RobertCraigie RobertCraigie released this 12 Jun 02:16
· 173 commits to main since this release
208233f

What's Changed

Support for Interactive Transactions

This release adds support for interactive transactions! This means you can safely group sets of queries into a single atomic transaction that will be rolled back if any step fails.

Quick example:

from prisma import Prisma

prisma = Prisma()
await prisma.connect()

async with prisma.tx() as transaction:
    user = await transaction.user.update(
        where={'id': from_user_id},
        data={'balance': {'decrement': 50}}
    )
    if user.balance < 0:
        raise ValueError(f'{user.name} does not have enough balance')

    await transaction.user.update(
        where={'id': to_user_id},
        data={'balance': {'increment': 50}}
    )

For more information see the docs.

Support for find_unique_or_raise & find_first_or_raise

This release adds two new client methods, find_unique_or_raise & find_first_or_raise which are the exact same as the respective find_unique & find_first methods but will raise an error if a record could not be found.

This is useful when you know that you should always find a given record as you won't have to explicitly handle the case where it isn't found anymore:

user = await db.user.find_unique_or_raise(
    where={
        'id': '...',
    },
    include={
        'posts': True,
    },
)

Prisma updates

This release bumps the internal Prisma version from v4.11.0 to v4.15.0.

Some of the highlights:

For the full release notes, see the v4.12.0, v4.13.0, v4.14.0 and v4.15.0 release notes.

Miscellaneous Changes

Sponsors

Huge thank you to @isometric & @techied for their continued support!

sponsors