MarcoPolo - delete_record()

This method removes a record from the database, identified by its Record ID.

Removing Records

Occasionally, you may find you need to remove records from the database and have to decide which from within your Elixir application. This function allows you to do so, removing records by their Record ID's.


delete_record(<conn>, <record-id>, <version>, <opts>)
  • <conn> Defines the database connection.
  • <record-id> Defines the Record ID, as an RID instance.
  • <version> Defines the record version.
  • <opts> Defines additional options for the function. For more information, see the Options section below.


This function provides two additional options:

  • :no_response Defines whether you want your application to wait for a response from OrientDB. When set to true, it returns :ok on every operation, regardless of whether it's successful.

  • :timeout Defines the timeout value in milliseconds. In the event that the query takes longer than the alloted time, MarcoPolo sends an exit signal to the calling process.

Return Values

When this operation is successful, the function returns the tuple {:ok, passed}, where the passed variable is a boolean value indicating whether the record was successfully deleted. In the event that the operation fails, it returns the tuple {:error, message}, where the variable contains the exception message.


Consider the use case where you need to remove a series of records from the database. Rather than calling delete_record() individually on each instance, you might want to create a function to handle the deletions.

@doc """Function to remove records from the database. It takes as arguments
the database connection interface and a list of tuples indicating
the records to remove.  Each tuple follows the pattern {cluster-id, [list of record id's]}."""
def remove_records(conn, record_list) do

	# Log Operation
	IO.puts("Removing Records")

	# Loop over Clusters
	for cluster <- record_list do
		# Fetch Cluster ID
		cluster_id =

		records = cluster.records

		# Loop Over Records
		for record <- records do

			# Construct RID
			rid = MarcoPolo.RID(cluster_id, record)
			# Remove Records
			MarcoPolo.delete_record(conn, rid)