Skip to content

Commit

Permalink
perf: updated to get user from the objectID
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruvdabhi101 committed Feb 14, 2024
1 parent 914a1bc commit 49b2bfe
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ To run this project you need to install


### Currently implemented Endpoints
- `GET /user/<username>`
- `GET /user/<username>`
- `POST /user` - to create new user ( registering )
- `POST /login` - to login into the account ( gets JWT Token back as response )
- `POST pages/create-page` - to create page, it will require JWT Token
Expand Down
5 changes: 3 additions & 2 deletions src/repository/mongodb_repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ impl MongoRepo {
.expect("Error Creating User");
Ok(user)
}
pub fn get_user(&self, username: &str) -> Result<UserFromMongo, Error> {
let filter = doc! {"username": username};
pub fn get_user(&self, id: &str) -> Result<UserFromMongo, Error> {
let user_id = bson::oid::ObjectId::from_str(id);
let filter = doc! {"_id": user_id.unwrap()};
let user_detail = self
.col
.find_one(filter, None)
Expand Down

0 comments on commit 49b2bfe

Please sign in to comment.