Hello,
I have a question on non database-backed models in Ecto.
The app I’m building is similar to Swagger Hub where API developers document their API. So imagine a user who built a “tasks” API can define their API schema (eg defining which fields exist on Task), create Operations (eg POST to /tasks), define authentication (eg an authentication token on every request), etc.
The models and their relationships might look like: an Account owns an API which owns a list of child Types (ie custom types such as a Task definition) which can have relationship with other custom Types. An API might also own a list of child Operations which also have relationships with custom Types.
However, for various reasons, I’d like all of this data about the API to be persisted as JSON in the Open API spec (https://swagger.io/docs/specification/about/) in the database instead of having an Operations table, a Types table, etc. The “actual” relationships might be an Account (stored as a regular table) has an API (stored as a regular table) which has a api_spec
json field.
My question is: how can I make this an implementation detail encapsulated to a small part of the app while the rest of the app treats these virtual models (and their relationships to other models) as regular, database-backed models? I’d like to follow standard patterns for the forms, validations, etc. and just have custom serialization/deserialization logic when it comes to loading/persisting this data.
Should I use embedded_schema? If so, would any model that has a relationship with a virtual model “embed” that relationship?
Thanks!
Vance