Skip to content

Document interactive transactions - #2098

Merged
matthewmueller merged 30 commits into
mainfrom
interactive-transactions
Aug 10, 2021
Merged

matthewmueller merged 30 commits into
mainfrom
interactive-transactions

Conversation

@matthewmueller

@matthewmueller matthewmueller commented Aug 4, 2021 •

Copy link
Copy Markdown
Contributor

This PR adds documentation for our upcoming Interactive Transactions feature.

Preview

Other changes:

  • I also tweaked a few pages that made references to long-running transactions.
  • For some reason the pre-commit hook refused to run because it wasn't executable, I ran chmod +x .husky/pre-commit to hopefully fix that.

@matthewmueller
matthewmueller requested a review from molebox August 4, 2021 21:38

TypeORM only offers limit-offset pagination while Prisma conveniently provides dedicated APIs for both limit-offset but also cursor-based. You can learn more about both approaches in the [Pagination](../../components/prisma-client/pagination) section of the docs or in the API comparison [below](#pagination-1).

### Transactions

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was debating whether or not to delete or rewrite this section.

There are still a few minor differences: they support isolation levels, we support more ways to do transactions. Decided it wasn't worth calling out as differences, but happy to revisit if you feel differently.

@molebox molebox left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Left a few minor changes and questions 😊

The following is an example of purchasing a movie ticket online. This is a good use case for an interactive transactions because you don't want to sell the same ticket twice.

```tsx
import { Ticket } from 'prisma'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a model type from the movie schema used in this example? Would this be importable from prisma ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, but you make a good point. This is not really clear without a Prisma Schema. I need to re-work this example anyways, so I'll address this in another PR.


In the example above, both the `findFirst` and `update` queries run within a database transaction. When your application reaches the end of the function, the transaction is **committed** to the database.

If your application encounters an error along the way, the async function will throw an exception and automatically **rollback** the transaction. To catch the exception, you can wrap `$transaction` in a try-catch block.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be helpful to show the try catch block. being as clear as possible will reduce the risk of people misunderstanding from a copy paste

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call, added!

matthewmueller and others added 25 commits August 9, 2021 15:38
…or on null values (#2077)

Clarify behaviour of null values with atomic number operations
* add npm install --save bson

* Update content/200-concepts/200-database-connectors/07-mongodb.mdx

Co-authored-by: Rich Haines <[email protected]>

Co-authored-by: Rich Haines <[email protected]>
* Cross linked debug info

* Added note to update table about migrate and schema - ref actions
Fix a few location where it used `model` but `data model` was meant.
…E_BINARY (#2069)

* fix(environment-variables-reference): Elaborate on PRISMA_QUERY_ENGINE_BINARY

* Update content/400-reference/200-api-reference/300-environment-variables-reference.mdx

Co-authored-by: Rich Haines <[email protected]>

Co-authored-by: Rich Haines <[email protected]>
* Cross linked debug info

* Changed import to new interface
* Cross linked debug info

* Fixed broken links on error code page
* Fix typo in docker-compose command

Missing "-" in ```docker-compose up -d```
The mongodb example did not make the authorId optional
* start porting constraint changes again

* remaining old content ported

* first round of fixes

* add feedback link

* tag fixes

* Fixed errors with tab component

* fix naming and broken links

add some todos

* Update content/200-concepts/100-components/01-prisma-schema/07-names-in-underlying-database.mdx

Co-authored-by: Jan Piotrowski <[email protected]>

* Update content/200-concepts/100-components/01-prisma-schema/07-names-in-underlying-database.mdx

Co-authored-by: Jan Piotrowski <[email protected]>

* Update content/300-guides/300-upgrade-guides/200-upgrading-to-latest/10-upgrade-to-2290.mdx

Co-authored-by: Jan Piotrowski <[email protected]>

* Added new upgrade structure and preview feature section

* Restructure `namedConstraints` preview feature guide page (#2112)

* Update content/200-concepts/100-components/01-prisma-schema/07-names-in-underlying-database.mdx

Co-authored-by: Jan Piotrowski <[email protected]>

* Update content/200-concepts/100-components/01-prisma-schema/07-names-in-underlying-database.mdx

Co-authored-by: Jan Piotrowski <[email protected]>

* incorporate datamodel feedback

* flesh out new structure for upgrade guide

Co-authored-by: Rich Haines <[email protected]>
Co-authored-by: Jan Piotrowski <[email protected]>
* Cross linked debug info

* Added new dev env section, moved files, changed links

* Update content/300-guides/125-development-environment/index.mdx

Co-authored-by: Hervé Labas <[email protected]>

Co-authored-by: Hervé Labas <[email protected]>
- Unify "Submit feedback" styling
- Add "since 2.x.0" with link to release notes
- Fix MongoDB feedback issue link
- Add referentialActions feedback link
- Sort by release version
* start restructuring upgrade guide

* finalized upgrade path structure

* preview feedback

* more formatting
* Cross linked debug info

* Moved ref actions down nav list, fixed code block indent

@molebox molebox left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🕺

@matthewmueller
matthewmueller merged commit c84c9b0 into main Aug 10, 2021
@matthewmueller
matthewmueller deleted the interactive-transactions branch August 10, 2021 17:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.