# Expose serialization of MutationRef in api?

**URL:** <https://forums.foundationdb.org/t/expose-serialization-of-mutationref-in-api/2124>\
**Category:** Development\
**Created:** [May 18, 2020, 7:15pm UTC](https://forums.foundationdb.org/t/expose-serialization-of-mutationref-in-api/2124 "2020-05-18T19:15:50Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![josephg](https://sea1.discourse-cdn.com/foundationdb/user_avatar/forums.foundationdb.org/josephg/32/84_2.png) [@josephg](https://forums.foundationdb.org/u/josephg)\
**Post date:** [May 21, 2020, 12:57am UTC](https://forums.foundationdb.org/t/expose-serialization-of-mutationref-in-api/2124/5 "2020-05-21T00:57:59Z")

</div>

Yeah I can see this being useful. I’ve been thinking of making some experimental changes to the nodejs bindings to support [realtime change feeds of key ranges](https://forums.foundationdb.org/t/getting-a-realtime-feed-of-changes/2116). With a feature like this it would be much simpler to do stuff like this:

- The bindings can expose a `beforeCommit` hook to user code. This is the only change we need in the bindings.
- A realtime change feed extension can then query back the set of local mutations and write metadata to a more durable operation log, or whatever.

As for encoding, the simplest implementation would be to just have the mirrored set of key/value pairs under `\xff\xff` that were written. So if a user does `tn.set('x', 'hi')` then I should later be able to `tn.getRange('\xff\xff' + 'mutations')` (or whatever) and get back `[['\xff\xff' + 'mutations' + 'x', 'hi'], ...]`. Then I can just strip off the prefix and read back the key/value pairs I set.

The other way to do it would be to have a single key contain all the key/value pair data encoded as tuples, since all bindings have a tuple encoder implementation already.

---

_[View the full topic](https://forums.foundationdb.org/t/expose-serialization-of-mutationref-in-api/2124)._
