MCPcopy
hub / github.com/wavetermdev/waveterm / DBResolveEasyOID

Function DBResolveEasyOID

pkg/wstore/wstore_dbops.go:240–260  ·  view source on GitHub ↗
(ctx context.Context, oid string)

Source from the content-addressed store, hash-verified

238}
239
240func DBResolveEasyOID(ctx context.Context, oid string) (*waveobj.ORef, error) {
241 return WithTxRtn(ctx, func(tx *TxWrap) (*waveobj.ORef, error) {
242 for _, rtype := range waveobj.AllWaveObjTypes() {
243 otype := reflect.Zero(rtype).Interface().(waveobj.WaveObj).GetOType()
244 table := tableNameFromOType(otype)
245 var fullOID string
246 if len(oid) == 8 {
247 query := fmt.Sprintf("SELECT oid FROM %s WHERE oid LIKE ?", table)
248 fullOID = tx.GetString(query, oid+"%")
249 } else {
250 query := fmt.Sprintf("SELECT oid FROM %s WHERE oid = ?", table)
251 fullOID = tx.GetString(query, oid)
252 }
253 if fullOID != "" {
254 oref := waveobj.MakeORef(otype, fullOID)
255 return &oref, nil
256 }
257 }
258 return nil, ErrNotFound
259 })
260}
261
262func DBSelectMap[T waveobj.WaveObj](ctx context.Context, ids []string) (map[string]T, error) {
263 rtnArr, err := dbSelectOIDs(ctx, getOTypeGen[T](), ids)

Callers 1

resolveUUIDFunction · 0.92

Calls 6

AllWaveObjTypesFunction · 0.92
MakeORefFunction · 0.92
tableNameFromOTypeFunction · 0.85
GetStringMethod · 0.80
WithTxRtnFunction · 0.70
GetOTypeMethod · 0.65

Tested by

no test coverage detected