pub struct CommentReaction {
pub id: i64,
pub comment_id: i64,
pub user_id: i64,
pub reaction: String,
pub created_at: Option<Timestamp>,
/* private fields */
}Expand description
A user’s reaction to a comment, from the comment_reactions table.
Fields§
§id: i64§comment_id: i64§user_id: i64§reaction: String§created_at: Option<Timestamp>Implementations§
Source§impl CommentReaction
impl CommentReaction
Sourcepub const comment_id: Column<Self, i64>
pub const comment_id: Column<Self, i64>
The comment_id column.
Sourcepub const created_at: Column<Self, Option<Timestamp>>
pub const created_at: Column<Self, Option<Timestamp>>
The created_at column.
Sourcepub fn find(
key: impl ComparableTo<i64>,
) -> impl Future<Output = Result<Option<Self>>> + Send
pub fn find( key: impl ComparableTo<i64>, ) -> impl Future<Output = Result<Option<Self>>> + Send
Find the row whose key is key, or return None when there’s no such row.
Sourcepub fn find_or_fail(
key: impl ComparableTo<i64>,
) -> impl Future<Output = Result<Self>> + Send
pub fn find_or_fail( key: impl ComparableTo<i64>, ) -> impl Future<Output = Result<Self>> + Send
Find the row whose key is key, or fail with a ModelNotFound error.
A ModelNotFound error renders as a 404 response.
Sourcepub fn find_many(
keys: impl IntoIterator<Item: Borrow<i64> + IntoExpr>,
) -> impl Future<Output = Result<Vec<Self>>> + Send
pub fn find_many( keys: impl IntoIterator<Item: Borrow<i64> + IntoExpr>, ) -> impl Future<Output = Result<Vec<Self>>> + Send
Find the rows whose keys are in keys.
Sourcepub fn first_where(
condition: impl IntoCondition,
) -> impl Future<Output = Result<Option<Self>>> + Send
pub fn first_where( condition: impl IntoCondition, ) -> impl Future<Output = Result<Option<Self>>> + Send
Find the first row that meets condition, or return None when no row does.
Sourcepub fn create() -> CommentReactionCreate
pub fn create() -> CommentReactionCreate
Start creating a row.
Set the row’s columns on the returned builder, then await the builder to insert the row and return the model as the database stored it.
Sourcepub fn destroy(
keys: impl IntoIterator<Item: Borrow<i64> + IntoExpr>,
) -> impl Future<Output = Result<u64>> + Send
pub fn destroy( keys: impl IntoIterator<Item: Borrow<i64> + IntoExpr>, ) -> impl Future<Output = Result<u64>> + Send
Find the models whose keys are in keys, then delete each one as delete does.
Each deletion runs the model’s deleting hook and dispatches its Deleted event. Returns
how many rows were deleted.
Sourcepub fn first_or_create(
condition: impl IntoCondition,
values: impl IntoCreate<Self>,
) -> FindOrCreate<Self>
pub fn first_or_create( condition: impl IntoCondition, values: impl IntoCreate<Self>, ) -> FindOrCreate<Self>
Find the first row that meets condition, or create a new row when no row does.
The new row takes its columns from the column = value comparisons that condition joins
with &, and values replaces those columns. eq(None) and is_null() give the column
NULL.
If another request inserts the row after the lookup, the insert violates a unique index, and
this method returns the other request’s row. Without a unique index, both requests insert a
row. Inside a transaction, the insert runs in a savepoint, so the violation doesn’t end the
transaction. found_or_created() reports whether this call inserted the row.
Sourcepub fn update_or_create(
condition: impl IntoCondition,
values: impl IntoCreate<Self>,
) -> FindOrCreate<Self>
pub fn update_or_create( condition: impl IntoCondition, values: impl IntoCreate<Self>, ) -> FindOrCreate<Self>
Update the first row that meets condition with the columns of values, or create a new
row when no row does.
The new row takes its columns from the column = value comparisons that condition joins
with &, and values replaces those columns. If the insert violates a unique index, this
method updates the first row that meets condition instead. When the create also creates
related models, it returns the database error rather than update the row.
found_or_created() reports whether this call inserted the row.
Sourcepub fn insert<V: IntoRow<Self>>(
rows: impl IntoIterator<Item = V>,
) -> impl Future<Output = Result<u64>> + Send
pub fn insert<V: IntoRow<Self>>( rows: impl IntoIterator<Item = V>, ) -> impl Future<Output = Result<u64>> + Send
Insert rows and return how many rows were inserted.
The rows are written with one statement per run of consecutive rows that set the same
columns, all in one transaction. Each row is a row! or a Fill struct, and gets both
timestamps. The insert runs no hooks,
dispatches no events, and doesn’t read the rows back. Inserting no rows runs no query.
Sourcepub fn upsert<V: IntoRow<Self>>(
rows: impl IntoIterator<Item = V>,
unique_by: impl Columns<Self>,
updates: impl Columns<Self>,
) -> impl Future<Output = Result<u64>> + Send
pub fn upsert<V: IntoRow<Self>>( rows: impl IntoIterator<Item = V>, unique_by: impl Columns<Self>, updates: impl Columns<Self>, ) -> impl Future<Output = Result<u64>> + Send
Insert rows as insert does, with one statement per run of consecutive rows that set the
same columns, all in one transaction, and update the rows that conflict on the unique_by
columns instead.
A conflicting row gets the updates columns and a new updated_at. Returns the number of
affected rows. MySQL counts an updated row twice.
Sourcepub fn update(&mut self) -> CommentReactionUpdate<'_>
pub fn update(&mut self) -> CommentReactionUpdate<'_>
Start updating the model.
Set the columns on the returned builder, then await the builder to write the columns that
changed. If the updating hook or the write fails, the model keeps its previous values.
After the write succeeds, it holds the new values even if an Updated listener fails.
Sourcepub fn increment<T>(
&mut self,
column: Column<Self, T>,
amount: T,
) -> CommentReactionUpdate<'_>
pub fn increment<T>( &mut self, column: Column<Self, T>, amount: T, ) -> CommentReactionUpdate<'_>
Start an update that adds amount to column, as column = column + amount, in both the
database and this model.
Sourcepub fn decrement<T>(
&mut self,
column: Column<Self, T>,
amount: T,
) -> CommentReactionUpdate<'_>
pub fn decrement<T>( &mut self, column: Column<Self, T>, amount: T, ) -> CommentReactionUpdate<'_>
Start an update that subtracts amount from column, as column = column - amount, in
both the database and this model.
Sourcepub fn delete_quietly(self) -> impl Future<Output = Result<()>> + Send
pub fn delete_quietly(self) -> impl Future<Output = Result<()>> + Send
Delete the model’s row without dispatching Deleted.
Sourcepub fn fresh(&self) -> impl Future<Output = Result<Option<Self>>> + Send + use<>
pub fn fresh(&self) -> impl Future<Output = Result<Option<Self>>> + Send + use<>
Load the model’s row as the database has it now, or return None when the row is gone.
Sourcepub fn refresh(&mut self) -> impl Future<Output = Result<()>> + Send + '_
pub fn refresh(&mut self) -> impl Future<Output = Result<()>> + Send + '_
Reload the model and its loaded relations from the database.
If the row is gone, this fails with ModelNotFound and leaves the model as it was.
Sourcepub fn update_values(
&mut self,
values: Values,
) -> impl Future<Output = Result<()>> + Send + '_
pub fn update_values( &mut self, values: Values, ) -> impl Future<Output = Result<()>> + Send + '_
Update the model’s row with values, as a query’s update_values does, then reload the
model as refresh does.
The update runs no hooks and dispatches no events.
Sourcepub fn is(&self, other: &Self) -> bool
pub fn is(&self, other: &Self) -> bool
Whether other is the same row, with the same key and read from the same connection.
A model that a cache or a request deserialized counts as read from the default connection.
PartialEq, when the model derives it, compares every column instead.
Sourcepub fn is_not(&self, other: &Self) -> bool
pub fn is_not(&self, other: &Self) -> bool
Whether other is a different row, the same as !self.is(other).
Sourcepub fn without_relations(&self) -> Self
pub fn without_relations(&self) -> Self
Copy the model’s columns, without any loaded or counted relationships.
Sourcepub fn replicate(&self) -> Replica<'_, Self>
pub fn replicate(&self) -> Replica<'_, Self>
The model’s columns for a new row, without its key and timestamps.
Use it to copy a row, as in create!(Post { title: "Copy", ..post.replicate() }).
Sourcepub fn load(
&mut self,
relations: impl IntoEager<Self>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + '_>>
pub fn load( &mut self, relations: impl IntoEager<Self>, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + '_>>
Load relations into this model. Pass one relation or a tuple of relations.
Sourcepub fn load_missing(
&mut self,
relations: impl IntoEager<Self>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + '_>>
pub fn load_missing( &mut self, relations: impl IntoEager<Self>, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + '_>>
Load relations into this model when it doesn’t hold them yet, as
ModelList::load_missing does.
Sourcepub fn load_count(
&mut self,
relations: impl IntoCount<Self>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + '_>>
pub fn load_count( &mut self, relations: impl IntoCount<Self>, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + '_>>
Count the related rows of relations for this model, as with_count does.
Sourcepub fn load_exists(
&mut self,
relations: impl IntoCount<Self>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + '_>>
pub fn load_exists( &mut self, relations: impl IntoCount<Self>, ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + '_>>
Check whether this model has related rows of relations, as with_exists does.
Sourcepub fn load_sum<__LaravelRelation, __LaravelTable, __LaravelValue>(
&mut self,
relation: __LaravelRelation,
column: Column<__LaravelTable, __LaravelValue>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + '_>>where
__LaravelRelation: IntoAggregate<Self>,
__LaravelTable: QueryTable<__LaravelRelation::Related>,
__LaravelValue: Numeric,
pub fn load_sum<__LaravelRelation, __LaravelTable, __LaravelValue>(
&mut self,
relation: __LaravelRelation,
column: Column<__LaravelTable, __LaravelValue>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + '_>>where
__LaravelRelation: IntoAggregate<Self>,
__LaravelTable: QueryTable<__LaravelRelation::Related>,
__LaravelValue: Numeric,
Add up column over this model’s related rows, as with_sum does.
Sourcepub fn load_max<__LaravelRelation, __LaravelTable, __LaravelValue>(
&mut self,
relation: __LaravelRelation,
column: Column<__LaravelTable, __LaravelValue>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + '_>>where
__LaravelRelation: IntoAggregate<Self>,
__LaravelTable: QueryTable<__LaravelRelation::Related>,
__LaravelValue: Ordered,
pub fn load_max<__LaravelRelation, __LaravelTable, __LaravelValue>(
&mut self,
relation: __LaravelRelation,
column: Column<__LaravelTable, __LaravelValue>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + '_>>where
__LaravelRelation: IntoAggregate<Self>,
__LaravelTable: QueryTable<__LaravelRelation::Related>,
__LaravelValue: Ordered,
Find the largest value of column among this model’s related rows, as with_max does.
Sourcepub fn load_min<__LaravelRelation, __LaravelTable, __LaravelValue>(
&mut self,
relation: __LaravelRelation,
column: Column<__LaravelTable, __LaravelValue>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + '_>>where
__LaravelRelation: IntoAggregate<Self>,
__LaravelTable: QueryTable<__LaravelRelation::Related>,
__LaravelValue: Ordered,
pub fn load_min<__LaravelRelation, __LaravelTable, __LaravelValue>(
&mut self,
relation: __LaravelRelation,
column: Column<__LaravelTable, __LaravelValue>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + '_>>where
__LaravelRelation: IntoAggregate<Self>,
__LaravelTable: QueryTable<__LaravelRelation::Related>,
__LaravelValue: Ordered,
Find the smallest value of column among this model’s related rows, as with_min does.
Sourcepub fn load_avg<__LaravelRelation, __LaravelTable, __LaravelValue>(
&mut self,
relation: __LaravelRelation,
column: Column<__LaravelTable, __LaravelValue>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + '_>>where
__LaravelRelation: IntoAggregate<Self>,
__LaravelTable: QueryTable<__LaravelRelation::Related>,
__LaravelValue: Numeric,
pub fn load_avg<__LaravelRelation, __LaravelTable, __LaravelValue>(
&mut self,
relation: __LaravelRelation,
column: Column<__LaravelTable, __LaravelValue>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + '_>>where
__LaravelRelation: IntoAggregate<Self>,
__LaravelTable: QueryTable<__LaravelRelation::Related>,
__LaravelValue: Numeric,
Average column over this model’s related rows, as with_avg does.
Trait Implementations§
Source§impl Clone for CommentReaction
impl Clone for CommentReaction
Source§impl Debug for CommentReaction
impl Debug for CommentReaction
Source§impl<S: Send + Sync> FromRequestParts<S> for CommentReaction
impl<S: Send + Sync> FromRequestParts<S> for CommentReaction
Source§impl FromRow for CommentReaction
impl FromRow for CommentReaction
Source§impl Hooks for CommentReaction
impl Hooks for CommentReaction
Source§fn creating(
_draft: &mut Draft<Self>,
) -> impl Future<Output = Result<(), Error>> + Send
fn creating( _draft: &mut Draft<Self>, ) -> impl Future<Output = Result<(), Error>> + Send
impl<__LaravelValues> IntoKeys<CommentReaction, __LaravelValues> for CommentReaction
impl<__LaravelValues> IntoKeys<CommentReaction, __LaravelValues> for &CommentReaction
impl<__LaravelValues> IntoKeys<CommentReaction, __LaravelValues> for i64
impl<__LaravelValues> IntoKeys<CommentReaction, __LaravelValues> for &i64
Source§impl Model for CommentReaction
impl Model for CommentReaction
Source§impl RouteModel for CommentReaction
impl RouteModel for CommentReaction
Source§impl RouteParam for CommentReaction
impl RouteParam for CommentReaction
Source§fn to_route_param(&self) -> String
fn to_route_param(&self) -> String
Auto Trait Implementations§
impl Forget for CommentReaction
impl Freeze for CommentReaction
impl Move for CommentReaction
impl RefUnwindSafe for CommentReaction
impl Send for CommentReaction
impl Sync for CommentReaction
impl Unpin for CommentReaction
impl UnsafeUnpin for CommentReactionwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
*const ArcInner<str> is !null: UnsafeUnpin,
PhantomData<ArcInner<str>>: UnsafeUnpin,
impl UnwindSafe for CommentReaction
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
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,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<K> ForeignKey<K> for K
impl<K> ForeignKey<K> for K
Source§impl<S, T> FromRequest<S, ViaParts> for T
impl<S, T> FromRequest<S, ViaParts> for T
Source§type Rejection = <T as FromRequestParts<S>>::Rejection
type Rejection = <T as FromRequestParts<S>>::Rejection
Source§fn from_request(
req: Request<Body>,
state: &S,
) -> impl Future<Output = Result<T, <T as FromRequest<S, ViaParts>>::Rejection>>
fn from_request( req: Request<Body>, state: &S, ) -> impl Future<Output = Result<T, <T as FromRequest<S, ViaParts>>::Rejection>>
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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> ⓘ
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> ⓘ
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 moreSource§impl<T> IntoViewData for Twhere
T: Serialize,
impl<T> IntoViewData for Twhere
T: Serialize,
Source§fn into_view_data(self) -> ViewData
fn into_view_data(self) -> ViewData
Source§impl<T, N> NotifiedBy<T> for Nwhere
T: Notification<N>,
impl<T, N> NotifiedBy<T> for Nwhere
T: Notification<N>,
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> RouteParams for Twhere
T: RouteParam,
impl<T> RouteParams for Twhere
T: RouteParam,
fn into_params<'a>(self) -> Params<'a>where
T: 'a,
Source§impl<T, V> UpdateValue<T> for Vwhere
V: FillValue<T>,
impl<T, V> UpdateValue<T> for Vwhere
V: FillValue<T>,
Source§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
Source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
Source§fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
Source§impl<M> __Models for Mwhere
M: Model,
impl<M> __Models for Mwhere
M: Model,
Source§const REQUIRED: bool = true
const REQUIRED: bool = true
Vec leaves the
missing model out instead.