Skip to content

Commit

Permalink
[merge] pull request #18 from akrck02/dev
Browse files Browse the repository at this point in the history
Fixed GetProject method adding pointer to found Project
  • Loading branch information
Itros97 authored May 22, 2024
2 parents da39f63 + f9394b5 commit c1830bc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
13 changes: 4 additions & 9 deletions services/project/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,29 +140,24 @@ func DeleteProject(conn context.Context, client *mongo.Client, project *models.P
// [param] conn | context.Context : The connection context
// [param] client | *mongo.Client : The mongo client
// [param] project | models.Project : The project to get
// [param] found | *models.Project : The project found
//
// [return] *models.Error : The error
func GetProject(conn context.Context, client *mongo.Client, project models.Project, found *models.Project) *models.Error { // get project from database
func GetProject(conn context.Context, client *mongo.Client, project models.Project) (*models.Project, *models.Error) { // get project from database

projects := client.Database(database.CurrentDatabase).Collection(database.PROJECT)

found := models.Project{}
err := projects.FindOne(conn, bson.M{"name": project.Name}).Decode(&found)

if err != nil {
return &models.Error{
return nil, &models.Error{
Status: http.HTTP_STATUS_NOT_FOUND,
Error: int(error.PROJECT_NOT_FOUND),
Message: "Project not found",
}
}

found = &models.Project{
Name: found.Name,
Description: found.Description,
}

return nil
return &found, nil
}

// Get all projects by user logic
Expand Down
2 changes: 1 addition & 1 deletion version.config
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.0.4
v0.0.5

0 comments on commit c1830bc

Please sign in to comment.