Defining our Database Transactions
Our transactions module is essentially the API for our data transactions. These transactions do not need interact with a data storage engine. Transactions could be API calls to another server, or a state machine. We will just focus on data storage engines, but when we implement these transactions, you will see how powerful and flexible they are.
Before we define any transactions however, we must ensure that our transactions are available with the code below:
// file: nanoservices/to_do/dal/src/to_do_items/transactions/mod.rs
pub mod create;
pub mod delete;
pub mod get;
pub mod update;
We can start our transaction definitions with the create
transaction. First, we must import the following:
// file: nanoservices/to_do/dal/src/to_do_items/
// transactions/create.rs
use crate::to_do_items::schema::{ToDoItem, NewToDoItem};
use glue::errors::NanoServiceError;
use std::future::Future;
#[cfg(feature = "json-file")]
use super::super::descriptors...