You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+13-6
Original file line number
Diff line number
Diff line change
@@ -11,13 +11,18 @@ Examples of using various popular database libraries and ORM in Go.
11
11
The aim is to demonstrate and compare usage for several operations
12
12
13
13
1. Simple CRUD operation
14
-
2. 1-1 queries
15
-
3. 1-to-Many queries
16
-
4. Many-to-many queries
17
-
5. Dynamic list filter from query parameter
18
-
6. Transaction
14
+
2. 1-to-Many queries
15
+
3. Many-to-many queries
16
+
4. Dynamic list filter from query parameter
17
+
5. Transaction
19
18
20
-
The schema contains optional fields, for example middle name, and a field that must not be returned, for example, a password.
19
+
# Schema
20
+
21
+

22
+
23
+
There are four tables. The `users` table and `addresses` table are linked by the pivot `user_addresses` table. The `addresses` table contains a foreign key to `countries` to demonstrate 1-to-many relationship.
24
+
25
+
To make things interesting, we make `middle_name` an optional field. We also have a 'protected/hidden' field in which we do not want to return in a JSON response, like a password.
21
26
22
27
23
28
# Usage
@@ -30,6 +35,8 @@ Setup postgres database by either running from docker-compose or manually.
30
35
31
36
This creates both `postgres` database (which this repo uses) and `ent` database which is used by ent ORM.
32
37
38
+
If you create the database manually, execute the `database/01-schema.sql` script.
39
+
33
40
Default database credentials are defined in `config/config.go`. These can be overwritten by setting environment variables. For example:
0 commit comments