| 148 | } |
| 149 | |
| 150 | func (d *sqliteModel) Delete(ctx context.Context, key string, v interface{}) error { |
| 151 | schema, err := d.schema(v) |
| 152 | if err != nil { |
| 153 | return err |
| 154 | } |
| 155 | query := fmt.Sprintf("DELETE FROM %q WHERE %q = ?", schema.Table, schema.Key) |
| 156 | result, err := d.db.ExecContext(ctx, query, key) |
| 157 | if err != nil { |
| 158 | return fmt.Errorf("model/sqlite: delete: %w", err) |
| 159 | } |
| 160 | n, _ := result.RowsAffected() |
| 161 | if n == 0 { |
| 162 | return model.ErrNotFound |
| 163 | } |
| 164 | return nil |
| 165 | } |
| 166 | |
| 167 | func (d *sqliteModel) List(ctx context.Context, result interface{}, opts ...model.QueryOption) error { |
| 168 | // result must be *[]*T |