-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
Certain applications don't use static JSON files to define their models, they create model definitions at runtime, often by running model discovery to obtain the model schema. Once the model is defined, the application usually exposed it via REST API.
This can be easily done in LB 3.x as follows:
const MyModel = app.registry.createModel(name, properties, settings);
app.model(MyModel, {dataSource: 'some-datasource', public: true});Let's find out how to allow LB 4.x users to do the same.
The scope of this spike is to research solutions for discovering and defining models in such way, that the infrastructure implemented in #2036 can pick up new definitions and build REST APIs.
Acceptance criteria
-
A proof-of-concept implementation of the necessary run-time parts.
-
A demo application providing a new REST API endpoint that will:
- Accept a MySQL connection string (host+port+database+credentials) and a list of table names.
- Connect to the specified MySQL database.
- Discover model schemas from the given tables
- Define LB4 models for the given tables
- Expose these models via REST API using From model definition to REST API with no custom repository/controller classes #2036
- Return a list of URL paths of the newly added models (e.g.
/Products,/CoffeeShops)
We can use the public database from loopback-getting-started) when testing this new endpoint manually.
-
List of GitHub issues - follow-up user stories covering the implementation. Documentation and blog post should be included in the implementation plan.
-
Decide what to do about relations. The story [EPIC] From relation definition to REST API with auto-generated repository/controller classes #2483 is tracking REST API for relations, but I don't think it's a good idea to include relations in the first iteration. Create a new GH issue to add support for discovery & definition of relations, this new issue can be a spike or the real implementation, depending on whether the implementation would be clear enough.