---
# System prepended metadata

title: Optimistic Engine

---

# Optimistic Engine

- sync key, lives both on store and on the SQLlite of browser
- event of update for that key
- interface for using data from db on render
- merge optmistic data with realistic data


## Modeling

### store

      --------------------------------------------------
    | projects                                          |
     ___________________________________________________
    |  id  | idempotency_key | created_at | updated_at |
    | uuid |      uuid       |    date    |    date    |
     --------------------------------------------------

### DB
     ----------------------------------------------------------------------
    | projects - indexes(id, idempotency_key)                              |
     ______________________________________________________________________
    |  id  | idempotency_key | created_at | updated_at |   queue    | data |
    | uuid |      uuid       |    date    |    date    | map of map | map  |
     ----------------------------------------------------------------------
 

## Tools
- dbs options
- [SQLlite](https://sqlitebrowser.org/)
- indexedDB
    - [Overview](https://www.codemag.com/Article/1411041/Introduction-to-IndexedDB-The-In-Browser-Database)
    - [Tutorial](https://medium.com/@AndyHaskell2013/build-a-basic-web-app-with-indexeddb-8ab4f83f8bda)
    - [Documentation](https://developer.mozilla.org/en-US/docs/Web/API/IDBDatabase)
    - [Compatibility](https://caniuse.com/#feat=indexeddb)
    - [Google developers tutorial](https://developers.google.com/web/ilt/pwa/lab-indexeddb)
    - [idb lib](https://github.com/jakearchibald/idb)