Skip to content

Commit 0e5ca57

Browse files
committed
models/user: Add async_email() fn
This is a clone of `email()`, but using `diesel_async`
1 parent 2f4ed8a commit 0e5ca57

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/models/user.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,17 @@ impl User {
113113
.first(conn)
114114
.optional()
115115
}
116+
117+
/// Queries for the email belonging to a particular user
118+
pub async fn async_email(&self, conn: &mut AsyncPgConnection) -> QueryResult<Option<String>> {
119+
use diesel_async::RunQueryDsl;
120+
121+
Email::belonging_to(self)
122+
.select(emails::email)
123+
.first(conn)
124+
.await
125+
.optional()
126+
}
116127
}
117128

118129
/// Represents a new user record insertable to the `users` table

0 commit comments

Comments
 (0)