FQL v4 will be decommissioned on June 30, 2025. Ensure that you complete your migration from FQL v4 to FQL v10 by that date.

For more details, see the v4 EOL announcement and migration guide. Contact support@fauna.com with any questions.

Abort

This reference topic applies to FQL v4. Go to this page for the latest FQL v10 reference topics.

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

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.

Parameters

Parameter

Type

Definition and Requirements

message

String

An abort message.

Returns

An error is returned with the associated abort message.

Examples

The following query 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.

client.query([
  q.CreateCollection({ name: 'cars' }),
  q.Now(),
  q.Abort('Reset Transaction'),
])
.then((ret) => console.log(ret))
.catch((err) => console.error(
  'Error: [%s] %s: %s',
  err.name,
  err.message,
  err.errors()[0].description,
))
Error: [BadRequest] transaction aborted: Reset Transaction
try:
  result = client.query(
    [
      q.create_collection({"name": "cars"}),
      q.now(),
      q.abort("Reset Transaction"),
    ]
  )
  print(result)
except:
  print("Error: ", sys.exc_info()[0], sys.exc_info()[1])
Error:  <class 'faunadb.errors.BadRequest'> ErrorData(code='transaction aborted', description='Reset Transaction', position=[2], failures=None)
result, err := client.Query(
	f.Arr{
		f.CreateCollection(f.Obj{ "name": "cars" }),
		f.Now(),
		f.Abort("Reset Transaction"),
	})

if err != nil {
	fmt.Fprintln(os.Stderr, err)
} else {
	fmt.Println(result)
}
Response error 400. Errors: [](transaction aborted): Reset Transaction, details: []
try
{
    Value result = await client.Query(
        Arr(
            CreateCollection(Obj("name", "cars")),
            Now(),
            Abort("Reset Transaction")
        )
    );

    Console.WriteLine(result);
}
catch (Exception e)
{
    Console.WriteLine($"ERROR: {e.Message}");
}
ERROR: transaction aborted: Reset Transaction
[
  CreateCollection({ name: 'cars' }),
  Now(),
  Abort('Reset Transaction'),
]
{
  errors: [
    {
      position: [
        2
      ],
      code: 'transaction aborted',
      description: 'Reset Transaction'
    }
  ]
}
Query metrics:
  •    bytesIn:   93

  •   bytesOut:   92

  • computeOps:    1

  •    readOps:    0

  •   writeOps:    0

  •  readBytes:  802

  • writeBytes:    0

  •  queryTime: 30ms

  •    retries:    0

Is this article helpful? 

Tell Fauna how the article can be improved:
Visit Fauna's forums or email docs@fauna.com

Thank you for your feedback!