Переглянути джерело

Fetching the user now retrieves all of the users accounts as well.

Lee Morgan 1 рік тому
батько
коміт
6abcc0774f
2 змінених файлів з 13 додано та 2 видалено
  1. 11 0
      bruno/Suma/User/Get.bru
  2. 2 2
      src/models/account.rs

+ 11 - 0
bruno/Suma/User/Get.bru

@@ -0,0 +1,11 @@
+meta {
+  name: Get
+  type: http
+  seq: 4
+}
+
+get {
+  url: http://localhost:8000/api/user
+  body: none
+  auth: inherit
+}

+ 2 - 2
src/models/account.rs

@@ -7,7 +7,7 @@ use crate::app_error::AppError;
 use crate::dto::account::CreateInput;
 use crate::models::user::User;
 
-#[derive(Serialize, Deserialize)]
+#[derive(Debug, Serialize, Deserialize)]
 pub struct Account {
     #[serde(rename = "_id")]
     pub id: ObjectId,
@@ -44,7 +44,7 @@ impl Account {
 
     pub async fn find_by_user(collection: &Collection<Account>, user_id: ObjectId) -> Result<Vec<Account>, AppError> {
         Ok(collection
-            .find(doc!{"_id": user_id}, None)
+            .find(doc!{"user": user_id}, None)
             .await?
             .try_collect::<Vec<_>>()
             .await?)