Skip to content

FeelHippo/repository_pattern

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Repository Pattern

  • See my investigation here
  • See my implementation of Inversion of Control here
  • Goal

In this little project, I explore and implement a basic [repository pattern](https://martinfowler.com/eaaCatalog/repository.html.

The role of the repository is to abstract data sources. The data source in this case, is a PostgreSQL database.

The data mapper pattern, in contrast to the active record pattern, ensures domain objects only contain business rules. Any task related to database operations is handed over to the data mapper layer.

The Repository Layer centralizes the query construction code, providing a more object-oriented way of communicating with a collection of objects.

Requests

GET ALL

curl --location 'localhost:8080/all-users'

GET BY ID

curl --location 'localhost:8080/user?id=1'

POST

curl --location 'localhost:8080/user' \
--header 'Content-Type: application/json' \
--data '{
    "name": "Elio"
}'

PUT

curl --location --request PUT 'localhost:8080/user?id=2' \
--header 'Content-Type: application/json' \
--data '{
    "name": "Filippo",
    "isDeleted": false
}'

DELETE

curl --location --request DELETE 'localhost:8080/user?id=2'

About

Understanding the Data Mapper Pattern and Repository Pattern

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published