MarcoPolo - create_record()

Creating Records

When you want to create new records, you can build Document instances within your Elixir application code and pass it to this method to add it to the database.

Syntax

create_record(<conn>, <cluster-id>, <data>, <opts>)

<conn> Defines the database connection.

<cluster-id> Defines the Cluster you want to use.

<data> Defines the data to use in the record.

<opts> Defines optional options to pass to the function. For more information on the available options, see Options below.

Options

This function takes the following options:

:no_response Defines whether the function should wait on a response from the OrientDB Server. If set false, it returns :ok regardless of whether or not the operation was 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 the function is successful, it returns the tuple {:ok, record_info}. The record_info value is a tuple containing the Record ID and record version. In the event that the record creation fails, it returns {:error, term}. The term variable provides the error message.

Example

For instance, consider the use case of a web application. You might want a function to streamline adding new blog entries to the database.