pub struct User {
pub id: i32,
pub email: String,
pub hash_password: String,
pub activated: bool,
pub created_at: DateTime<Utc>,
pub updated_at: DateTime<Utc>,
}
Fields§
§id: i32
§email: String
§hash_password: String
§activated: bool
§created_at: DateTime<Utc>
§updated_at: DateTime<Utc>
Implementations§
Source§impl User
impl User
Sourcepub fn create(db: &mut Connection, item: &UserChangeset) -> QueryResult<Self>
pub fn create(db: &mut Connection, item: &UserChangeset) -> QueryResult<Self>
Create an entry in db
’s users
table using the data in item
§Errors
diesel::result::Error
if the query fails
Sourcepub fn read(db: &mut Connection, item_id: i32) -> QueryResult<Self>
pub fn read(db: &mut Connection, item_id: i32) -> QueryResult<Self>
Read from db
, querying for an entry in the users
who’s primary key matches item_id
§Errors
diesel::result::Error
if the query fails
Sourcepub fn find_by_email(
db: &mut Connection,
item_email: String,
) -> QueryResult<Self>
pub fn find_by_email( db: &mut Connection, item_email: String, ) -> QueryResult<Self>
Queries db
’s users
table for an entry
with an email that matches the given item_email
§Errors
diesel::result::Error
if the query fails
Sourcepub fn read_all(
db: &mut Connection,
pagination: &PaginationParams,
) -> QueryResult<Vec<Self>>
pub fn read_all( db: &mut Connection, pagination: &PaginationParams, ) -> QueryResult<Vec<Self>>
Read from db
, return entries of the users
table,
paginated according to pagination
§Errors
diesel::result::Error
if the query fails
Sourcepub fn update(
db: &mut Connection,
item_id: i32,
item: &UserChangeset,
) -> QueryResult<Self>
pub fn update( db: &mut Connection, item_id: i32, item: &UserChangeset, ) -> QueryResult<Self>
Update the entry in db
’s users
table who’s primary key matches
item_id
, with the data in item
§Errors
diesel::result::Error
if the query fails
Sourcepub fn delete(db: &mut Connection, item_id: i32) -> QueryResult<usize>
pub fn delete(db: &mut Connection, item_id: i32) -> QueryResult<usize>
Delete the entry in db
’s users
table who’s
primary key matches item_id
§Errors
diesel::result::Error
if the query fails
Trait Implementations§
Source§impl<'update> AsChangeset for &'update User
impl<'update> AsChangeset for &'update User
Source§type Changeset = <(Grouped<Eq<email, <&'update String as AsExpression<<email as Expression>::SqlType>>::Expression>>, Grouped<Eq<hash_password, <&'update String as AsExpression<<hash_password as Expression>::SqlType>>::Expression>>, Grouped<Eq<activated, <&'update bool as AsExpression<<activated as Expression>::SqlType>>::Expression>>, Grouped<Eq<created_at, <&'update DateTime<Utc> as AsExpression<<created_at as Expression>::SqlType>>::Expression>>, Grouped<Eq<updated_at, <&'update DateTime<Utc> as AsExpression<<updated_at as Expression>::SqlType>>::Expression>>) as AsChangeset>::Changeset
type Changeset = <(Grouped<Eq<email, <&'update String as AsExpression<<email as Expression>::SqlType>>::Expression>>, Grouped<Eq<hash_password, <&'update String as AsExpression<<hash_password as Expression>::SqlType>>::Expression>>, Grouped<Eq<activated, <&'update bool as AsExpression<<activated as Expression>::SqlType>>::Expression>>, Grouped<Eq<created_at, <&'update DateTime<Utc> as AsExpression<<created_at as Expression>::SqlType>>::Expression>>, Grouped<Eq<updated_at, <&'update DateTime<Utc> as AsExpression<<updated_at as Expression>::SqlType>>::Expression>>) as AsChangeset>::Changeset
The update statement this type represents
Source§fn as_changeset(self) -> <Self as AsChangeset>::Changeset
fn as_changeset(self) -> <Self as AsChangeset>::Changeset
Convert
self
into the actual update statement being executedSource§impl AsChangeset for User
impl AsChangeset for User
Source§type Changeset = <(Grouped<Eq<email, <String as AsExpression<<email as Expression>::SqlType>>::Expression>>, Grouped<Eq<hash_password, <String as AsExpression<<hash_password as Expression>::SqlType>>::Expression>>, Grouped<Eq<activated, <bool as AsExpression<<activated as Expression>::SqlType>>::Expression>>, Grouped<Eq<created_at, <DateTime<Utc> as AsExpression<<created_at as Expression>::SqlType>>::Expression>>, Grouped<Eq<updated_at, <DateTime<Utc> as AsExpression<<updated_at as Expression>::SqlType>>::Expression>>) as AsChangeset>::Changeset
type Changeset = <(Grouped<Eq<email, <String as AsExpression<<email as Expression>::SqlType>>::Expression>>, Grouped<Eq<hash_password, <String as AsExpression<<hash_password as Expression>::SqlType>>::Expression>>, Grouped<Eq<activated, <bool as AsExpression<<activated as Expression>::SqlType>>::Expression>>, Grouped<Eq<created_at, <DateTime<Utc> as AsExpression<<created_at as Expression>::SqlType>>::Expression>>, Grouped<Eq<updated_at, <DateTime<Utc> as AsExpression<<updated_at as Expression>::SqlType>>::Expression>>) as AsChangeset>::Changeset
The update statement this type represents
Source§fn as_changeset(self) -> <Self as AsChangeset>::Changeset
fn as_changeset(self) -> <Self as AsChangeset>::Changeset
Convert
self
into the actual update statement being executedSource§impl<__FK> BelongsTo<&User> for UserPermissionwhere
__FK: Hash + Eq,
for<'__a> &'__a i32: Into<Option<&'__a __FK>>,
for<'__a> &'__a User: Identifiable<Id = &'__a __FK>,
impl<__FK> BelongsTo<&User> for UserPermissionwhere
__FK: Hash + Eq,
for<'__a> &'__a i32: Into<Option<&'__a __FK>>,
for<'__a> &'__a User: Identifiable<Id = &'__a __FK>,
Source§type ForeignKey = __FK
type ForeignKey = __FK
The foreign key of this struct
Source§type ForeignKeyColumn = user_id
type ForeignKeyColumn = user_id
The database column representing the foreign key
of the table this struct represents
Source§fn foreign_key(&self) -> Option<&Self::ForeignKey>
fn foreign_key(&self) -> Option<&Self::ForeignKey>
Returns the foreign key for
self
Source§fn foreign_key_column() -> Self::ForeignKeyColumn
fn foreign_key_column() -> Self::ForeignKeyColumn
Returns the foreign key column of this struct’s table
Source§impl<__FK> BelongsTo<&User> for UserSessionwhere
__FK: Hash + Eq,
for<'__a> &'__a i32: Into<Option<&'__a __FK>>,
for<'__a> &'__a User: Identifiable<Id = &'__a __FK>,
impl<__FK> BelongsTo<&User> for UserSessionwhere
__FK: Hash + Eq,
for<'__a> &'__a i32: Into<Option<&'__a __FK>>,
for<'__a> &'__a User: Identifiable<Id = &'__a __FK>,
Source§type ForeignKey = __FK
type ForeignKey = __FK
The foreign key of this struct
Source§type ForeignKeyColumn = user_id
type ForeignKeyColumn = user_id
The database column representing the foreign key
of the table this struct represents
Source§fn foreign_key(&self) -> Option<&Self::ForeignKey>
fn foreign_key(&self) -> Option<&Self::ForeignKey>
Returns the foreign key for
self
Source§fn foreign_key_column() -> Self::ForeignKeyColumn
fn foreign_key_column() -> Self::ForeignKeyColumn
Returns the foreign key column of this struct’s table
Source§impl<__FK> BelongsTo<User> for UserPermissionwhere
__FK: Hash + Eq,
for<'__a> &'__a i32: Into<Option<&'__a __FK>>,
for<'__a> &'__a User: Identifiable<Id = &'__a __FK>,
impl<__FK> BelongsTo<User> for UserPermissionwhere
__FK: Hash + Eq,
for<'__a> &'__a i32: Into<Option<&'__a __FK>>,
for<'__a> &'__a User: Identifiable<Id = &'__a __FK>,
Source§type ForeignKey = __FK
type ForeignKey = __FK
The foreign key of this struct
Source§type ForeignKeyColumn = user_id
type ForeignKeyColumn = user_id
The database column representing the foreign key
of the table this struct represents
Source§fn foreign_key(&self) -> Option<&Self::ForeignKey>
fn foreign_key(&self) -> Option<&Self::ForeignKey>
Returns the foreign key for
self
Source§fn foreign_key_column() -> Self::ForeignKeyColumn
fn foreign_key_column() -> Self::ForeignKeyColumn
Returns the foreign key column of this struct’s table
Source§impl<__FK> BelongsTo<User> for UserSessionwhere
__FK: Hash + Eq,
for<'__a> &'__a i32: Into<Option<&'__a __FK>>,
for<'__a> &'__a User: Identifiable<Id = &'__a __FK>,
impl<__FK> BelongsTo<User> for UserSessionwhere
__FK: Hash + Eq,
for<'__a> &'__a i32: Into<Option<&'__a __FK>>,
for<'__a> &'__a User: Identifiable<Id = &'__a __FK>,
Source§type ForeignKey = __FK
type ForeignKey = __FK
The foreign key of this struct
Source§type ForeignKeyColumn = user_id
type ForeignKeyColumn = user_id
The database column representing the foreign key
of the table this struct represents
Source§fn foreign_key(&self) -> Option<&Self::ForeignKey>
fn foreign_key(&self) -> Option<&Self::ForeignKey>
Returns the foreign key for
self
Source§fn foreign_key_column() -> Self::ForeignKeyColumn
fn foreign_key_column() -> Self::ForeignKeyColumn
Returns the foreign key column of this struct’s table
Source§impl<'de> Deserialize<'de> for User
impl<'de> Deserialize<'de> for User
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<'ident> Identifiable for &'ident User
impl<'ident> Identifiable for &'ident User
Auto Trait Implementations§
impl Freeze for User
impl RefUnwindSafe for User
impl Send for User
impl Sync for User
impl Unpin for User
impl UnwindSafe for User
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
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 moreSource§impl<T> IntoSql for T
impl<T> IntoSql for T
Source§fn into_sql<T>(self) -> Self::Expression
fn into_sql<T>(self) -> Self::Expression
Convert
self
to an expression for Diesel’s query builder. Read moreSource§fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
Convert
&self
to an expression for Diesel’s query builder. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T, ST, DB> StaticallySizedRow<ST, DB> for T
impl<T, ST, DB> StaticallySizedRow<ST, DB> for T
Source§const FIELD_COUNT: usize = <ST as crate::util::TupleSize>::SIZE
const FIELD_COUNT: usize = <ST as crate::util::TupleSize>::SIZE
The number of fields that this type will consume.