@josephg just released version 0.8.0 of the Node bindings, which are available on GitHub here: https://github.com/josephg/node-foundationdb
Important updates include bumping the supported FDB version to 600, improving the ergonomics of the Versionstamp API, and adding Versionstamp support to the tuple layer.
import * as fdb from 'foundationdb'
const db = fdb.openSync().withKeyEncoding(fdb.encoders.tuple)
const key1 = [1,2,3, fdb.tuple.unboundVersionstamp()]
const key2 = [1,2,3, fdb.tuple.unboundVersionstamp()]
await db.doTn(async tn => {
tn.setVersionstampedKey(key1, '1')
tn.setVersionstampedKey(key2, '2') // Does not overwrite first insert!
})
// key1 is [1,2,3, {type: 'versionstamp', value: Buffer<10 bytes followed by 0x00, 0x00>}]
// key2 is [1,2,3, {type: 'versionstamp', value: Buffer<10 bytes followed by 0x00, 0x01>}]
// You can override this behaviour by baking an explicit code into your call to `tuple.unboundVersionstamp`:
const key = [1,2,3, fdb.tuple.unboundVersionstamp(321)]
After the transaction commits the keys are modified to replace the unbound versionstamp with actual versionstamp.