@@ -26,10 +26,10 @@ type Connection interface {
26
26
27
27
// WithStructFieldNamer returns a copy of the connection
28
28
// that will use the passed StructFieldNamer.
29
- WithStructFieldNamer (namer StructFieldNamer ) Connection
29
+ WithStructFieldNamer (namer StructFieldMapper ) Connection
30
30
31
31
// StructFieldNamer used by methods of this Connection.
32
- StructFieldNamer () StructFieldNamer
32
+ StructFieldNamer () StructFieldMapper
33
33
34
34
// Ping returns an error if the database
35
35
// does not answer on this connection
@@ -66,37 +66,17 @@ type Connection interface {
66
66
// and returns values from the inserted row listed in returning.
67
67
InsertReturning (table string , values Values , returning string ) RowScanner
68
68
69
- // InsertStruct inserts a new row into table using the exported fields
70
- // of rowStruct which have a `db` tag that is not "-".
71
- // If restrictToColumns are provided, then only struct fields with a `db` tag
72
- // matching any of the passed column names will be used.
73
- InsertStruct (table string , rowStruct any , restrictToColumns ... string ) error
74
-
75
- // InsertStructNonDefault inserts a new row into table using the exported fields
76
- // of rowStruct which have a `db` tag that is not "-".
77
- // Struct fields with the `db` tags ",default" or ",readonly" will not be inserted.
78
- InsertStructNonDefault (table string , rowStruct any ) error
79
-
80
- // TODO insert multiple structs with single query if possible
81
- // InsertStructs(table string, rowStructs any, restrictToColumns ...string) error
82
-
83
- // InsertStructIgnoreColumns inserts a new row into table using the exported fields
84
- // of rowStruct which have a `db` tag that is not "-".
85
- // Struct fields with a `db` tag matching any of the passed ignoreColumns will not be used.
86
- InsertStructIgnoreColumns (table string , rowStruct any , ignoreColumns ... string ) error
87
-
88
- // InsertUniqueStruct inserts a new row into table using the exported fields
89
- // of rowStruct which have a `db` tag that is not "-".
90
- // If restrictToColumns are provided, then only struct fields with a `db` tag
91
- // matching any of the passed column names will be used.
92
- // Does nothing if the onConflict statement applies and returns if a row was inserted.
93
- InsertUniqueStruct (table string , rowStruct any , onConflict string , restrictToColumns ... string ) (inserted bool , err error )
69
+ // InsertStruct inserts a new row into table using the connection's
70
+ // StructFieldNamer to map struct fields to column names.
71
+ // Optional ColumnFilter can be passed to ignore mapped columns.
72
+ InsertStruct (table string , rowStruct any , ignoreColumns ... ColumnFilter ) error
94
73
95
- // InsertUniqueStructIgnoreColumns inserts a new row into table using the exported fields
96
- // of rowStruct which have a `db` tag that is not "-".
97
- // Struct fields with a `db` tag matching any of the passed ignoreColumns will not be used.
98
- // Does nothing if the onConflict statement applies and returns if a row was inserted.
99
- InsertUniqueStructIgnoreColumns (table string , rowStruct any , onConflict string , ignoreColumns ... string ) (inserted bool , err error )
74
+ // InsertUniqueStruct inserts a new row into table using the connection's
75
+ // StructFieldNamer to map struct fields to column names.
76
+ // Optional ColumnFilter can be passed to ignore mapped columns.
77
+ // Does nothing if the onConflict statement applies
78
+ // and returns if a row was inserted.
79
+ InsertUniqueStruct (table string , rowStruct any , onConflict string , ignoreColumns ... ColumnFilter ) (inserted bool , err error )
100
80
101
81
// Update table rows(s) with values using the where statement with passed in args starting at $1.
102
82
Update (table string , values Values , where string , args ... any ) error
@@ -115,14 +95,7 @@ type Connection interface {
115
95
// matching any of the passed column names will be used.
116
96
// The struct must have at least one field with a `db` tag value having a ",pk" suffix
117
97
// to mark primary key column(s).
118
- UpdateStruct (table string , rowStruct any , restrictToColumns ... string ) error
119
-
120
- // UpdateStructIgnoreColumns updates a row in a table using the exported fields
121
- // of rowStruct which have a `db` tag that is not "-".
122
- // Struct fields with a `db` tag matching any of the passed ignoreColumns will not be used.
123
- // The struct must have at least one field with a `db` tag value having a ",pk" suffix
124
- // to mark primary key column(s).
125
- UpdateStructIgnoreColumns (table string , rowStruct any , ignoreColumns ... string ) error
98
+ UpdateStruct (table string , rowStruct any , ignoreColumns ... ColumnFilter ) error
126
99
127
100
// UpsertStruct upserts a row to table using the exported fields
128
101
// of rowStruct which have a `db` tag that is not "-".
@@ -131,15 +104,7 @@ type Connection interface {
131
104
// The struct must have at least one field with a `db` tag value having a ",pk" suffix
132
105
// to mark primary key column(s).
133
106
// If inserting conflicts on the primary key column(s), then an update is performed.
134
- UpsertStruct (table string , rowStruct any , restrictToColumns ... string ) error
135
-
136
- // UpsertStructIgnoreColumns upserts a row to table using the exported fields
137
- // of rowStruct which have a `db` tag that is not "-".
138
- // Struct fields with a `db` tag matching any of the passed ignoreColumns will not be used.
139
- // The struct must have at least one field with a `db` tag value having a ",pk" suffix
140
- // to mark primary key column(s).
141
- // If inserting conflicts on the primary key column(s), then an update is performed.
142
- UpsertStructIgnoreColumns (table string , rowStruct any , ignoreColumns ... string ) error
107
+ UpsertStruct (table string , rowStruct any , ignoreColumns ... ColumnFilter ) error
143
108
144
109
// QueryRow queries a single row and returns a RowScanner for the results.
145
110
QueryRow (query string , args ... any ) RowScanner
0 commit comments