MCPcopy
hub / github.com/micro/go-micro / Read

Method Read

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

Source from the content-addressed store, hash-verified

111}
112
113func (d *sqliteModel) Read(ctx context.Context, key string, v interface{}) error {
114 schema, err := d.schema(v)
115 if err != nil {
116 return err
117 }
118 cols := columnList(schema)
119 query := fmt.Sprintf("SELECT %s FROM %q WHERE %q = ?", cols, schema.Table, schema.Key)
120 row := d.db.QueryRowContext(ctx, query, key)
121 fields, err := scanRow(schema, row)
122 if err != nil {
123 return err
124 }
125 model.MapToStruct(schema, fields, v)
126 return nil
127}
128
129func (d *sqliteModel) Update(ctx context.Context, v interface{}) error {
130 schema, err := d.schema(v)

Callers

nothing calls this directly

Calls 4

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

Tested by

no test coverage detected