Description / Steps to reproduce / Feature proposal
lb4 repository command will generate the basic repository file for a given name. It is better than copy-pasting and editing files.
Current Behavior
There is no lb4 repository command.
Expected Behavior
We should have lb4 repository command.
Acceptance Criteria
See Reporting Issues for more tips on writing good issues
Description / Steps to reproduce / Feature proposal
lb4 repositorycommand will generate the basic repository file for a given name. It is better than copy-pasting and editing files.Current Behavior
There is no
lb4 repositorycommand.Expected Behavior
We should have
lb4 repositorycommand.Acceptance Criteria
lb4 repositorycommand to@loopback/cli. Works as follows:DataSource Selection (Detect in project using https://github.com/strongloop/loopback-next/blob/master/packages/cli/lib/utils.js#L210). (Infer binding key based on Boot Conventions).
Detect the type of Repository (DefaultCrudRepository / KVRepository) based on the DataSource (No prompt).
Model Selection (Detect in project using https://github.com/strongloop/loopback-next/blob/master/packages/cli/lib/utils.js#L210). This will be a multiple choice question allowing a user to select multiple models to back to same DataSource. We will generate a new class for each selected model.
Prompt for type of
idfield in Model ... if we can't infer by inspecting theModelclass ourselves (Ex: Check ifidproperty exists and set astypeof Todo.prototype.idin model or check metadata for which field is theid... if both fail then prompt the user.Use templates to generate the appropriate repository artifact as
/src/repositories/<modelName>.<dataSourceName>repository.ts--configmode is supported (Can pass in answers to all prompts using JSON).See Reporting Issues for more tips on writing good issues