Skip to content

Commit f116065

Browse files
committed
models/user: Add async_verified_email() fn
1 parent 2f4ed8a commit f116065

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/models/user.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,22 @@ impl User {
104104
.optional()
105105
}
106106

107+
/// Queries the database for the verified emails
108+
/// belonging to a given user
109+
pub async fn async_verified_email(
110+
&self,
111+
conn: &mut AsyncPgConnection,
112+
) -> QueryResult<Option<String>> {
113+
use diesel_async::RunQueryDsl;
114+
115+
Email::belonging_to(self)
116+
.select(emails::email)
117+
.filter(emails::verified.eq(true))
118+
.first(conn)
119+
.await
120+
.optional()
121+
}
122+
107123
/// Queries for the email belonging to a particular user
108124
pub fn email(&self, conn: &mut impl Conn) -> QueryResult<Option<String>> {
109125
use diesel::RunQueryDsl;

0 commit comments

Comments
 (0)