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

Function DBGetAllObjsByType

pkg/wstore/wstore_dbops.go:220–238  ·  view source on GitHub ↗
(ctx context.Context, otype string)

Source from the content-addressed store, hash-verified

218}
219
220func DBGetAllObjsByType[T waveobj.WaveObj](ctx context.Context, otype string) ([]T, error) {
221 return WithTxRtn(ctx, func(tx *TxWrap) ([]T, error) {
222 rtn := make([]T, 0)
223 table := tableNameFromOType(otype)
224 query := fmt.Sprintf("SELECT oid, version, data FROM %s", table)
225 var rows []idDataType
226 tx.Select(&rows, query)
227 for _, row := range rows {
228 waveObj, err := waveobj.FromJson(row.Data)
229 if err != nil {
230 return nil, err
231 }
232 waveobj.SetVersion(waveObj, row.Version)
233
234 rtn = append(rtn, waveObj.(T))
235 }
236 return rtn, nil
237 })
238}
239
240func DBResolveEasyOID(ctx context.Context, oid string) (*waveobj.ORef, error) {
241 return WithTxRtn(ctx, func(tx *TxWrap) (*waveobj.ORef, error) {

Callers 8

GetAllJobManagerStatusFunction · 0.92
pruneUnusedJobsFunction · 0.92
onConnectionUpFunction · 0.92
GetNumJobsRunningFunction · 0.92
ReconnectJobsForConnFunction · 0.92
ListWorkspacesFunction · 0.92
SwitchWorkspaceFunction · 0.92

Calls 4

FromJsonFunction · 0.92
SetVersionFunction · 0.92
tableNameFromOTypeFunction · 0.85
WithTxRtnFunction · 0.70

Tested by

no test coverage detected