OxL Reference

data KvTx

The view of the store inside Kv.txn.

Example:

oxl✓ checked in CI
use std.kv { Kv }

fn main() io, db {
  let kv = Kv.open("docs-kvtx")!
  kv.put("balance", b"10")!
  let r = kv.txn(tx => {
    let old = tx.get("balance") ?? b""
    tx.put("balance", b"20")
    old.len()
  })
  print("{r!}")
  kv.close()
}
Output
2
@derive(Copy)
pub(api) data KvTx

Since. 1.0.0-beta

Fields

pub(api) t: i64

Handle of the transaction in the runtime.

Methods

get(key: str) -> bytes?
The value of key as this transaction sees it (its own writes included), or none.
put(key: str, value: bytes)
Stores value under key when the transaction commits.
delete(key: str)
Removes key when the transaction commits.

Defined in: std/kv/kv.oxl:232

See also