File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed
crates/crates_io_database/src/models/trustpub Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change 11mod github_config;
2+ mod used_jti;
23
34pub use self :: github_config:: { GitHubConfig , NewGitHubConfig } ;
5+ pub use self :: used_jti:: NewUsedJti ;
Original file line number Diff line number Diff line change 1+ use crate :: schema:: trustpub_used_jtis;
2+ use chrono:: { DateTime , Utc } ;
3+ use diesel:: prelude:: * ;
4+ use diesel_async:: { AsyncPgConnection , RunQueryDsl } ;
5+
6+ #[ derive( Debug , Insertable ) ]
7+ #[ diesel( table_name = trustpub_used_jtis, check_for_backend( diesel:: pg:: Pg ) ) ]
8+ pub struct NewUsedJti < ' a > {
9+ pub jti : & ' a str ,
10+ pub expires_at : DateTime < Utc > ,
11+ }
12+
13+ impl < ' a > NewUsedJti < ' a > {
14+ pub fn new ( jti : & ' a str , expires_at : DateTime < Utc > ) -> Self {
15+ Self { jti, expires_at }
16+ }
17+
18+ pub async fn insert ( & self , conn : & mut AsyncPgConnection ) -> QueryResult < usize > {
19+ diesel:: insert_into ( trustpub_used_jtis:: table)
20+ . values ( self )
21+ . execute ( conn)
22+ . await
23+ }
24+ }
You can’t perform that action at this time.
0 commit comments