(ctx context.Context, key string, v interface{})
| 109 | } |
| 110 | |
| 111 | func (d *postgresModel) Read(ctx context.Context, key string, v interface{}) error { |
| 112 | schema, err := d.schema(v) |
| 113 | if err != nil { |
| 114 | return err |
| 115 | } |
| 116 | cols := columnList(schema) |
| 117 | query := fmt.Sprintf("SELECT %s FROM %s WHERE %s = $1", cols, quoteIdent(schema.Table), quoteIdent(schema.Key)) |
| 118 | row := d.db.QueryRowContext(ctx, query, key) |
| 119 | fields, err := scanRow(schema, row) |
| 120 | if err != nil { |
| 121 | return err |
| 122 | } |
| 123 | model.MapToStruct(schema, fields, v) |
| 124 | return nil |
| 125 | } |
| 126 | |
| 127 | func (d *postgresModel) Update(ctx context.Context, v interface{}) error { |
| 128 | schema, err := d.schema(v) |
nothing calls this directly
no test coverage detected