MCPcopy Create free account
hub / github.com/micro/go-micro / Read

Method Read

model/postgres/postgres.go:111–125  ·  view source on GitHub ↗
(ctx context.Context, key string, v interface{})

Source from the content-addressed store, hash-verified

109}
110
111func (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
127func (d *postgresModel) Update(ctx context.Context, v interface{}) error {
128 schema, err := d.schema(v)

Callers

nothing calls this directly

Calls 5

schemaMethod · 0.95
MapToStructFunction · 0.92
quoteIdentFunction · 0.85
columnListFunction · 0.70
scanRowFunction · 0.70

Tested by

no test coverage detected