Lee Morgan 1 год назад
Родитель
Сommit
6b94621862
2 измененных файлов с 5 добавлено и 5 удалено
  1. 1 1
      bruno/Suma/User/Create.bru
  2. 4 4
      src/models/account.rs

+ 1 - 1
bruno/Suma/User/Create.bru

@@ -12,7 +12,7 @@ post {
 
 body:json {
   {
-    "email": "lee2@leemorgan.dev",
+    "email": "lee@leemorgan.dev",
     "password_hash": "leerobertmorgan",
     "password_salt": "leerobertmorgan"
   }

+ 4 - 4
src/models/account.rs

@@ -9,8 +9,8 @@ use crate::models::user::User;
 
 #[derive(Serialize, Deserialize)]
 pub struct Account {
-    #[serde(rename = "_id", skip_serializing_if = "Option::is_none")]
-    pub _id: Option<ObjectId>,
+    #[serde(rename = "_id")]
+    pub id: ObjectId,
     pub user: ObjectId,
     pub data: String,
     pub created_at: DateTime
@@ -26,7 +26,7 @@ pub struct ResponseAccount {
 impl Account {
     pub async fn insert(collection: &Collection<Account>, input: CreateInput, user: User) -> Result<ObjectId, AppError> {
         let account = Account {
-            _id: None,
+            id: ObjectId::new(),
             user: user.id,
             data: input.data,
             created_at: DateTime::now()
@@ -60,7 +60,7 @@ impl Account {
 
     pub fn response(self) -> ResponseAccount {
         ResponseAccount {
-            id: self._id.unwrap().to_string(),
+            id: self.id.to_string(),
             data: self.data.clone(),
             created_at: self.created_at.timestamp_millis()
         }