Skip to content

Commit

Permalink
feat: update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
1995parham committed Sep 22, 2024
1 parent 061ae31 commit 5327f05
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,16 @@ curl 127.0.0.1:1373/v1/students/89846857
]
}
```

## Preload

When you have a relation in your database, you can use `gorm.Preload` to fetch the related information within your
query, under the hood GORM run `N+1` queries as follows:

```text
2024/09/22 04:09:21 /Users/parham/Documents/Git/parham/1995parham-teaching/students-fall-2022/internal/store/student/sql.go:102
[0.081ms] [rows:0] SELECT * FROM `students_courses` WHERE `students_courses`.`sql_item_id` = "27849651"
2024/09/22 04:09:21 /Users/parham/Documents/Git/parham/1995parham-teaching/students-fall-2022/internal/store/student/sql.go:102
[0.691ms] [rows:1] SELECT * FROM `students` WHERE `students`.`id` = "27849651" LIMIT 1
```

0 comments on commit 5327f05

Please sign in to comment.