Export Ecto 2 data to JavaScript

I have mutliple Repo setup. Each repo has own ecto prefix (PostrgreSQL schema).
I want to create dynamic offline mode.
I do not use IndexedDB yet, so I have some questions:

  1. Is it possible to export (server side) Repo (single - not all) structure and import it in IndexedDB (client side)?
  2. Is it possible to rerference tables in different IndexedDB databases (like in PostgreSQL schema)?
    I see mix ecto.dump (with -r / --repo option) task, but can I import in IndexedDB PostgreSQL dump?
1 Like

I find an easy way to do this. Simply I can write a module that can be used like:

defmodule MyModule do
  use MyOtherModule, model: MyModel

and provide in __use__ macro a generated method that retuns info from __schema__ function for selected model.
I could be used in WebSocket channel and easily called from JavaScript.
Optionally it’s possible to map a List of modules and for each module collect data from __schema__ function.