#[no_mangle]
pub extern "C" fn rorm_db_query_optional(
    db: &'static Database,
    transaction: Option<&'static mut Transaction>,
    model: FFIString<'static>,
    columns: FFISlice<'static, FFIColumnSelector<'static>>,
    joins: FFISlice<'static, FFIJoin<'static>>,
    condition: Option<&'static FFICondition<'_>>,
    order_by: FFISlice<'static, FFIOrderByEntry<'static>>,
    offset: FFIOption<u64>,
    callback: Option<unsafe extern "C" fn(_: usize, _: Option<Box<Row>>, _: Error<'_>)>,
    context: usize
)
Expand description

This function queries the database given the provided parameter and returns one optional matched row. If no results could be retrieved, None is returned.

To include the statement in a transaction specify transaction as a valid Transaction. As the Transaction needs to be mutable, it is important to not use the Transaction anywhere else until the callback is finished.

If the statement should be executed not in a Transaction, specify a null pointer.

Parameter:

  • db: Reference to the Database, provided by rorm_db_connect.
  • transaction: Mutable pointer to a Transaction. Can be a null pointer to ignore this parameter.
  • model: Name of the table to query.
  • columns: Array of columns to retrieve from the database.
  • joins: Array of joins to add to the query.
  • condition: Pointer to a [Condition].
  • order_by: Array of FFIOrderByEntry.
  • offset: Optional offset to set to the query.
  • callback: callback function. Takes the context, a pointer to a row and an Error.
  • context: Pass through void pointer.

Important:

  • Make sure that db, model, columns, joins and condition are allocated until the callback is executed.

This function is called from an asynchronous context.