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: cmd/generate-database/README.md
+6
Original file line number
Diff line number
Diff line change
@@ -35,6 +35,9 @@ This will initiate a call to `generate-database db mapper generate`,
35
35
which will then search for `//generate-database:mapper` directives in the same file
36
36
and process those.
37
37
38
+
The following flags are available:
39
+
*`--package` / `-p`: Package import paths to search for structs to parse. Defaults to the caller package. Can be used more than once.
40
+
38
41
#### File
39
42
40
43
Generally the first thing we will want to do for any newly generated file is to
@@ -83,6 +86,8 @@ Type | Description
83
86
:--- | :----
84
87
`objects` | Creates a basic SELECT statement of the form `SELECT <columns> FROM <table> ORDER BY <columns>`.
85
88
`objects-by-<FIELD>-and-<FIELD>...` | Parses a pre-existing SELECT statement variable declaration of the form produced by`objects`, and appends a `WHERE` clause with the given fields located in the associated struct. Specifically looks for a variable declaration of the form `var <entity>Objects = RegisterStmt("SQL String")`
89
+
`names` | Creates a basic SELECT statement of the form `SELECT <primary key> FROM <table> ORDER BY <primary key>`.
90
+
`names-by-<FIELD>-and-<FIELD>...` | Parses a pre-existing SELECT statement variable declaration of the form produced by`names`, and appends a `WHERE` clause with the given fields located in the associated struct. Specifically looks for a variable declaration of the form `var <entity>Objects = RegisterStmt("SQL String")`
86
91
`create` | Creates a basic INSERT statement of the form `INSERT INTO <table> VALUES`.
87
92
`create-or-replace` | Creates a basic INSERT statement of the form `INSERT OR REPLACE INTO <table> VALUES`.
88
93
`delete-by-<FIELD>-and-<FIELD>...` | Creates a DELETE statement of the form `DELETE FROM <table> WHERE <constraint>` where the constraint is based on the given fields of the associated struct.
@@ -123,6 +128,7 @@ Go function generation supports the following types:
123
128
124
129
Type | Description
125
130
:--- | :----
131
+
`GetNames` | Return a slice of primary keys for all rows in a table matching the filter. Cannot be used with composite keys.
126
132
`GetMany` | Return a slice of structs for all rows in a table matching the filter.
127
133
`GetOne` | Return a single struct corresponding to a row with the given primary keys. Depends on `GetMany`.
128
134
`ID` | Return the ID column from the table corresponding to the given primary keys.
0 commit comments