> reimplement IndexedDB using FoundationDB. IndexedDB is also a key value..
I did sth pretty similar last month: https://rxdb.info/rx-storage-foundationdb.html
It supports indexes, mongoDB queries etc. to store and query JSON documents via RxDB on top of FoundationDB.