pub struct PostgresReadModelStore { /* private fields */ }Expand description
Postgres implementation of ReadModelStore.
Implementations§
Source§impl PostgresReadModelStore
impl PostgresReadModelStore
Sourcepub async fn new(database_url: &str) -> ReadModelResult<Self>
pub async fn new(database_url: &str) -> ReadModelResult<Self>
Build a new store from a database URL, creating a small pool.
Sourcepub fn with_pool(pool: PgPool) -> Self
pub fn with_pool(pool: PgPool) -> Self
Build a store from an existing pool. Lets tests share one pool with the event store against the same database.
Sourcepub async fn initialize_schema(&self) -> ReadModelResult<()>
pub async fn initialize_schema(&self) -> ReadModelResult<()>
Create the users_view projection table and its email index if absent.
Idempotent.
Trait Implementations§
Source§impl Clone for PostgresReadModelStore
impl Clone for PostgresReadModelStore
Source§fn clone(&self) -> PostgresReadModelStore
fn clone(&self) -> PostgresReadModelStore
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl ReadModelStore for PostgresReadModelStore
impl ReadModelStore for PostgresReadModelStore
Source§fn upsert<'life0, 'async_trait>(
&'life0 self,
op: Upsert,
) -> Pin<Box<dyn Future<Output = ReadModelResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn upsert<'life0, 'async_trait>(
&'life0 self,
op: Upsert,
) -> Pin<Box<dyn Future<Output = ReadModelResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Insert or update a row, version-gated. Read more
Source§fn delete<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
table: &'life1 str,
key: &'life2 str,
) -> Pin<Box<dyn Future<Output = ReadModelResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn delete<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
table: &'life1 str,
key: &'life2 str,
) -> Pin<Box<dyn Future<Output = ReadModelResult<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Delete a row by primary key. No-op if missing.
Source§fn get<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
table: &'life1 str,
key: &'life2 str,
) -> Pin<Box<dyn Future<Output = ReadModelResult<Option<Row>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn get<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
table: &'life1 str,
key: &'life2 str,
) -> Pin<Box<dyn Future<Output = ReadModelResult<Option<Row>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Fetch a single row by primary key.
Source§fn find_by<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
table: &'life1 str,
field: &'life2 str,
value: &'life3 Value,
) -> Pin<Box<dyn Future<Output = ReadModelResult<Vec<Row>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn find_by<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
table: &'life1 str,
field: &'life2 str,
value: &'life3 Value,
) -> Pin<Box<dyn Future<Output = ReadModelResult<Vec<Row>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Fetch all rows where
field equals value. Used for secondary-index
lookups such as login-by-email. Backends may or may not have an index
on the field — the trait carries no guarantee.Auto Trait Implementations§
impl !RefUnwindSafe for PostgresReadModelStore
impl !UnwindSafe for PostgresReadModelStore
impl Freeze for PostgresReadModelStore
impl Send for PostgresReadModelStore
impl Sync for PostgresReadModelStore
impl Unpin for PostgresReadModelStore
impl UnsafeUnpin for PostgresReadModelStore
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more