(ctx context.Context, otype string)
| 105 | } |
| 106 | |
| 107 | func DBGetSingletonByType(ctx context.Context, otype string) (waveobj.WaveObj, error) { |
| 108 | return WithTxRtn(ctx, func(tx *TxWrap) (waveobj.WaveObj, error) { |
| 109 | table := tableNameFromOType(otype) |
| 110 | query := fmt.Sprintf("SELECT oid, version, data FROM %s LIMIT 1", table) |
| 111 | var row idDataType |
| 112 | found := tx.Get(&row, query) |
| 113 | if !found { |
| 114 | return nil, ErrNotFound |
| 115 | } |
| 116 | rtn, err := waveobj.FromJson(row.Data) |
| 117 | if err != nil { |
| 118 | return rtn, err |
| 119 | } |
| 120 | waveobj.SetVersion(rtn, row.Version) |
| 121 | return rtn, nil |
| 122 | }) |
| 123 | } |
| 124 | |
| 125 | func DBExistsORef(ctx context.Context, oref waveobj.ORef) (bool, error) { |
| 126 | return WithTxRtn(ctx, func(tx *TxWrap) (bool, error) { |
no test coverage detected