Skip to content

how can I use prepared transactions? #626

Closed
@massivefermion

Description

@massivefermion

I'm working on a project where I need to implement distributed transactions. After some research, we came to the conclusion that we should use postgresql's prepared transactions.
But the problem is, begin does not support prepared transactions. So I tried, e.g:

sql.unsafe(`begin; insert into users (username) values (${username}); prepare transaction 'insert_user';`)

But this gives the following error:

Uncaught Error: UNSAFE_TRANSACTION: Only use sql.begin or max: 1

Is it possible to use prepared transactions at all? If yes, how?
Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions