Abort
Abort( message )
Abort( message )
Abort( message )
Not available in this language yet.
Not available in this language yet.
Not available in this language yet.
Not available in this language yet.
Not available in this language yet.
Description
The 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 are ignored, even if this
modification took place before the abort function was executed.
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"))),
Now(),
Abort("Reset Transaction")
)
).get());
client.query([
q.CreateCollection({ name: 'cars' }),
q.Now(),
q.Abort('Reset Transaction'),
])
.then((ret) => console.log(ret))
.catch((err) => console.log('Error:', err))
println(Await.result(
client.query(
Arr(
CreateCollection(Obj("name" -> "cars")),
Now(),
Abort("Reset Transaction")
)
),
5.seconds
))
Not available in this language yet.
Not available in this language yet.
Not available in this language yet.
Not available in this language yet.
Not available in this language yet.
[WARNING]
java.util.concurrent.ExecutionException: com.faunadb.client.errors.BadRequestException: transaction aborted: Reset Transaction
Error: { [BadRequest: transaction aborted]
name: 'BadRequest',
message: 'transaction aborted',
requestResult:
RequestResult {
client:
Client {
_baseUrl: 'http://localhost:8443',
_timeout: 60000,
_secret: 'secret',
_observer: null,
_lastSeen: 1574192104670000,
_keepAliveEnabledAgent: [Agent] },
method: 'POST',
path: '',
query: null,
requestRaw:
'[{"create_collection":{"object":{"name":"cars"}}},{"now":null},{"abort":"Reset Transaction"}]',
requestContent: Expr { raw: [Array] },
responseRaw:
'{"errors":[{"position":[2],"code":"transaction aborted","description":"Reset Transaction"}]}',
responseContent: { errors: [Array] },
statusCode: 400,
responseHeaders:
{ connection: 'keep-alive',
'content-length': '92',
'content-type': 'application/json;charset=utf-8',
'x-faunadb-build': '2.10.0.nightly20191113-157960d',
'x-query-bytes-in': '93',
'x-query-bytes-out': '92',
'x-query-time': '13',
'x-read-ops': '0',
'x-storage-bytes-read': '0',
'x-storage-bytes-write': '0',
'x-txn-retries': '0',
'x-txn-time': '1574192104670000',
'x-write-ops': '1' },
startTime: 1574192104611,
endTime: 1574192104654 } }
[error] (run-main-0) faunadb.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!