feat: function to initialize personal library

when signup (OS-25)
This commit is contained in:
Artemy 2022-07-27 12:41:51 +03:00
parent d18e7ea2e7
commit 136ad52e7d

View file

@ -112,6 +112,19 @@ impl Core {
} }
} }
async fn create_personal_library(&self, name: &String) {
self.personal_libraries
.insert_one(
doc! {
"name":name,
"apps":[]
},
None,
)
.await
.unwrap();
}
pub async fn get_reviews(&self, app_name_id: &String) -> Vec<Document> { pub async fn get_reviews(&self, app_name_id: &String) -> Vec<Document> {
self.get_collection_with_params(&self.reviews, doc! {"app_name_id":app_name_id}) self.get_collection_with_params(&self.reviews, doc! {"app_name_id":app_name_id})
.await .await
@ -342,6 +355,7 @@ impl Core {
let response = self.users.insert_one(&auth_info, None).await; let response = self.users.insert_one(&auth_info, None).await;
match response { match response {
Ok(_) => { Ok(_) => {
self.create_personal_library(&user.name).await;
json! ({ json! ({
"code":"ok", "code":"ok",
"token":token "token":token