forked from RedHatOfficial/GoCourse
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlesson10_ru.slide
More file actions
175 lines (99 loc) · 3.62 KB
/
lesson10_ru.slide
File metadata and controls
175 lines (99 loc) · 3.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
Урок 10. Базы данных
Lesson 10
27 Jul 2025
Tags: golang, go
Перевод команды GoCourse
Stanislav Zeman <zeman@standa.dev>
ModernTV s.r.o.
https://github.com/RedHatOfficial/GoCourse
@RedHat
* Источники
- [[https://github.com/RedHatOfficial/GoCourse]]
.image ./common/qr_address.png
* Gophers
#The Go gopher was designed by Renee French. (http://reneefrench.blogspot.com/)
#Source https://golang.org/doc/gopher/fiveyears.jpg
#The design and this image is licensed under the Creative Commons 3.0 Attributions license.
.image ./common/fiveyears.jpg _ 900
* Использование
.code lesson10/sql.go
* Типы запросов
- *Exec*: когда строки не возвращаются
.code lesson10/sql_exec.go
- *QueryRow*: когда ожидается максимум одна строка
.code lesson10/sql_query_row.go
* Типы запросов
- *Query*: когда возвращается несколько значений
.code lesson10/sql_query.go
* GORM
- полнофункциональная ORM
- высокоуровневая
- [[https://gorm.io/index.html][страница проекта GORM]]
* Демонстрация
.code lesson10/gorm_showcase.go
* Модель
.code lesson10/gorm_model.go
* ID
.code lesson10/gorm_id.go
* ID (переопределённый)
.code lesson10/gorm_overwritten_id.go
* Tabler
.code lesson10/gorm_tabler.go
* Snake Case
.code lesson10/gorm_snake_case.go
* Теги колонок
.code lesson10/gorm_column_tags.go
* CreatedAt
.code lesson10/gorm_created_at.go
* CreatedAt отключён
.code lesson10/gorm_disabled_created_at.go
* Создание
.code lesson10/gorm_create.go
* Создание нескольких записей
.code lesson10/gorm_create_multiple.go
* Создание с выбранными полями
.code lesson10/gorm_create_selected_fields.go
* Чтение
.code lesson10/gorm_read.go
* Чтение по первичному ключу
.code lesson10/gorm_read_pk.go
* Чтение всех записей
.code lesson10/gorm_read_all.go
* Условия чтения
.code lesson10/gorm_read_conditions.go
* Save и Create
.code lesson10/gorm_save_create.go
* Save
.code lesson10/gorm_save.go
* Обновление одного поля
.code lesson10/gorm_update_single.go
* Обновление нескольких полей
.code lesson10/gorm_update_multiple.go
* Пакетное обновление
.code lesson10/gorm_update_batch.go
* Удаление по первичному ключу
.code lesson10/gorm_delete_pk.go
* Пакетное удаление
.code lesson10/gorm_batch_delete.go
* Пакетное удаление с первичными ключами
.code lesson10/gorm_batch_delete_with_pk.go
* Мягкое удаление
.code lesson10/gorm_soft_delete.go
* Объявление связи "Один ко многим"
.code lesson10/gorm_has_many_declare.go
* Получение связанных записей
.code lesson10/gorm_has_many_retrieve.go
* Объявление связи "Многие ко многим"
.code lesson10/gorm_many_to_many_declare.go
* Получение связанных записей
.code lesson10/gorm_many_to_many_retrieve.go
* Raw SQL
.code lesson10/gorm_raw_sql.go
* Raw SQL Exec
.code lesson10/gorm_raw_sql_exec.go
#last slide
* Больше Gophers
#The Go gopher was designed by Renee French. (http://reneefrench.blogspot.com/)
#Source https://golang.org/doc/gopher/bumper.png
#The design and this image is licensed under the Creative Commons 3.0 Attributions license.
.image ./common/bumper.png _ 900