File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed
rust-workspace/projects/data-server/src/data_handlers Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,11 @@ use chrono::prelude::*;
77use serde:: Deserialize ;
88use std:: env;
99
10+ #[ derive( Deserialize ) ]
11+ pub struct UserData {
12+ pub id : String ,
13+ }
14+
1015#[ derive( Deserialize ) ]
1116pub struct NewDataPool {
1217 pub id : String ,
@@ -28,15 +33,15 @@ pub fn scoped_config(cfg: &mut web::ServiceConfig) {
2833}
2934
3035// This function accepts application data
31- async fn get_data ( data : web:: Data < Mutex < Client > > ) -> impl Responder {
36+ async fn get_data ( data : web:: Data < Mutex < Client > > , existingUser : web :: Json < UserData > ) -> impl Responder {
3237 let data_collection = data
3338 . lock ( )
3439 . unwrap ( )
3540 . database ( MONGO_DB )
3641 . collection ( MONGO_COLLECTION ) ;
3742
38- let filter = doc ! { } ;
39- // Tweak find options to find specific user's data
43+ let userId = & existingUser . id ;
44+ let filter = doc ! { "userId" : userId } ;
4045 let find_options = FindOptions :: builder ( ) . sort ( doc ! { "_id" : -1 } ) . build ( ) ;
4146 let mut cursor = data_collection. find ( filter, find_options) . await . unwrap ( ) ;
4247
@@ -74,4 +79,4 @@ async fn add_data(data: web::Data<Mutex<Client>>, new_pool: web::Json<NewDataPoo
7479 return HttpResponse :: InternalServerError ( ) . finish ( )
7580 }
7681 }
77- }
82+ }
You can’t perform that action at this time.
0 commit comments