Abort

Abort( message )
Abort( message )
Abort( message )
Abort( message )
abort ( message )
abort  message
Abort( message )
Abort( message )

Description

This Abort function terminates the current transaction and augments the returned error with the associated message. Any modifications to data or schema in the aborted transaction will be ignored, even if this modification took place before the abort function was executed.

Parameters

Argument

Type

Definition and Requirements

message

String

An abort message.

Returns

An error is returned with the associated abort message.

Examples

The query below is a single transaction with three statements. The first statement creates a collection, the second statement adds an document to the collection, and the third statement aborts the transaction. Due to the transaction being terminated by the Abort call, neither the creation of the collection nor the addition of the document is present in the database.

System.out.println(client.query(
     Arr(
       CreateCollection(Obj("name", Value("cars"))),
       Create(
            Collection("cars"),
            Obj( "data", Obj( "name", Value("Ford") ) )),
       Abort("Reset Transaction")
     )
).get());
ERROR java.util.concurrent.ExecutionException:
         com.faunadb.client.errors.BadRequestException: transaction aborted: Reset Transaction

Was this article helpful?

We're sorry to hear that.
Tell us how we can improve! documentation@fauna.com

Thank you for your feedback!