1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//! SQLite persistence helpers for Mostro domain types.
//!
//! Enabled by the `sqlx` Cargo feature. The [`Crud`] trait is the local
//! replacement for the unmaintained `sqlx-crud` crate: it provides typed
//! `create`, `update`, and `by_id` operations against SQLite tables whose
//! rows map via [`sqlx::FromRow`].
use Future;
use ;
use Uuid;
/// Create, read-by-id, and update operations for a single SQLite table row.
///
/// Implementors are expected to map one struct to one table (for example
/// [`crate::order::Order`] → `orders`). IDs are assigned in application code
/// before insert, matching the previous `#[external_id]` behaviour of
/// `sqlx-crud`.
///
/// # Example
///
/// ```ignore
/// use mostro_core::db::Crud;
/// use mostro_core::order::Order;
///
/// let order = Order::default();
/// let order = order.create(&pool).await?;
/// let order = order.update(&pool).await?;
/// let maybe = Order::by_id(&pool, order.id).await?;
/// ```