Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add transaction example with customer as a parameter #36

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

NathaelB
Copy link

@NathaelB NathaelB commented Jan 6, 2025

πŸ”— Linked issue

No issue

❓ Type of change

  • πŸ‘Œ Enhancement (improving an existing functionality like performance)

πŸ“š Description

I've added a presentation of how to give the transaction as a client via the builder.
As I'm not documented, several people came to ask me privately how they could do this, so I took the initiative of adding this little piece of code.

@@ -170,6 +170,21 @@ await db.transaction(async (trx) => {
// highlight-end
```

It is possible to give the transaction as a customer, here is a simple example.
Copy link
Member

Choose a reason for hiding this comment

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

What does this sentence means?

Copy link
Author

Choose a reason for hiding this comment

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

The aim is to document the fact that you can create an entity with an await Foo.create(..) and give it the transaction.

Currently, the documentation shows that you can do a new Foo() and modify the fields manually. This solution of passing the trx to the client exists and documenting it could I think help several people.

I think I phrased the sentence wrong, what do you think about:

Instead of instantiating your entity using the new keyword, you can give the transaction in the client as a parameter.

@NathaelB
Copy link
Author

I push the modification, are you happy with this change?

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.

2 participants