@@ -205,28 +205,76 @@ type IndexableTable interface {
205
205
IndexKeyValues (* Context , []string ) (PartitionIndexKeyValueIter , error )
206
206
}
207
207
208
- // Inserter allow rows to be inserted in them.
209
- type Inserter interface {
210
- // Insert the given row.
208
+ // InsertableTable is a table that can process insertion of new rows.
209
+ type InsertableTable interface {
210
+ // Inserter returns an Inserter for this table. The Inserter will get one call to Insert() for each row to be
211
+ // inserted, and will end with a call to Close() to finalize the insert operation.
212
+ Inserter (* Context ) RowInserter
213
+ }
214
+
215
+ // RowInserter is an insert cursor that can insert one or more values to a table.
216
+ type RowInserter interface {
217
+ // Insert inserts the row given, returning an error if it cannot. Insert will be called once for each row to process
218
+ // for the insert operation, which may involve many rows. After all rows in an operation have been processed, Close
219
+ // is called.
211
220
Insert (* Context , Row ) error
221
+ // Close finalizes the insert operation, persisting its result.
222
+ Close (* Context ) error
223
+ }
224
+
225
+ // DeleteableTable is a table that can process the deletion of rows
226
+ type DeletableTable interface {
227
+ // Deleter returns a RowDeleter for this table. The RowDeleter will get one call to Delete for each row to be deleted,
228
+ // and will end with a call to Close() to finalize the delete operation.
229
+ Deleter (* Context , Row ) RowDeleter
230
+ }
231
+
232
+ // RowDeleter is a delete cursor that can delete one or more rows from a table.
233
+ type RowDeleter interface {
234
+ // Delete deletes the given row. Returns ErrDeleteRowNotFound if the row was not found. Delete will be called once for
235
+ // each row to process for the delete operation, which may involve many rows. After all rows have been processed,
236
+ // Close is called.
237
+ Delete (* Context , Row ) error
238
+ // Close finalizes the delete operation, persisting the result.
239
+ Close (* Context ) error
240
+ }
241
+
242
+ type Closer interface {
243
+ Close (* Context ) error
212
244
}
213
245
214
- // Deleter allow rows to be deleted from tables.
215
- type Deleter interface {
216
- // Delete the given row. Returns ErrDeleteRowNotFound if the row was not found.
246
+ type RowReplacer interface {
247
+ // Insert inserts the row given, returning an error if it cannot. Insert will be called once for each row to process
248
+ // for the replace operation, which may involve many rows. After all rows in an operation have been processed, Close
249
+ // is called.
250
+ Insert (* Context , Row ) error
251
+ // Delete deletes the given row. Returns ErrDeleteRowNotFound if the row was not found. Delete will be called once for
252
+ // each row to process for the delete operation, which may involve many rows. After all rows have been processed,
253
+ // Close is called.
217
254
Delete (* Context , Row ) error
255
+ // Close finalizes the replace operation, persisting the result.
256
+ Close (* Context ) error
218
257
}
219
258
220
259
// Replacer allows rows to be replaced through a Delete (if applicable) then Insert.
221
- type Replacer interface {
222
- Deleter
223
- Inserter
260
+ type ReplaceableTable interface {
261
+ // Replacer returns a RowReplacer for this table. The RowReplacer will have Insert and optionally Delete called once
262
+ // for each row, followed by a call to Close() when all rows have been processed.
263
+ Replacer () RowReplacer
264
+ }
265
+
266
+ // UpdateableTable is a table that can process updates of existing rows via update statements.
267
+ type UpdatableTable interface {
268
+ // Updater returns a RowUpdater for this table. The RowUpdater will have Update called once for each row to be
269
+ // updated, followed by a call to Close() when all rows have been processed.
270
+ Updater (ctx * Context ) RowUpdater
224
271
}
225
272
226
- // Updater allows rows to be updated.
227
- type Updater interface {
273
+ type RowUpdater interface {
228
274
// Update the given row. Provides both the old and new rows.
229
275
Update (ctx * Context , old Row , new Row ) error
276
+ // Close finalizes the delete operation, persisting the result.
277
+ Close (* Context ) error
230
278
}
231
279
232
280
// Database represents the database.
0 commit comments