(ctx context.Context, val waveobj.WaveObj)
| 343 | } |
| 344 | |
| 345 | func DBInsert(ctx context.Context, val waveobj.WaveObj) error { |
| 346 | oid := waveobj.GetOID(val) |
| 347 | if oid == "" { |
| 348 | return fmt.Errorf("cannot insert %T value with empty id", val) |
| 349 | } |
| 350 | jsonData, err := waveobj.ToJson(val) |
| 351 | if err != nil { |
| 352 | return err |
| 353 | } |
| 354 | return WithTx(ctx, func(tx *TxWrap) error { |
| 355 | table := waveObjTableName(val) |
| 356 | waveobj.SetVersion(val, 1) |
| 357 | query := fmt.Sprintf("INSERT INTO %s (oid, version, data) VALUES (?, ?, ?)", table) |
| 358 | tx.Exec(query, oid, 1, jsonData) |
| 359 | waveobj.ContextAddUpdate(ctx, waveobj.WaveObjUpdate{UpdateType: waveobj.UpdateType_Update, OType: val.GetOType(), OID: oid, Obj: val}) |
| 360 | return nil |
| 361 | }) |
| 362 | } |
| 363 | |
| 364 | func DBFindTabForBlockId(ctx context.Context, blockId string) (string, error) { |
| 365 | return WithTxRtn(ctx, func(tx *TxWrap) (string, error) { |
no test coverage detected