Skip to content

[CLI] add lb4 repository command #1588

@hacksparrow

Description

@hacksparrow

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

  • Add lb4 repository command 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 id field in Model ... if we can't infer by inspecting the Model class ourselves (Ex: Check if id property exists and set as typeof Todo.prototype.id in model or check metadata for which field is the id ... if both fail then prompt the user.

    • Use templates to generate the appropriate repository artifact as /src/repositories/<modelName>.<dataSourceName>repository.ts

  • Tests + Docs
    • Ensure --config mode is supported (Can pass in answers to all prompts using JSON).
  • Blog

See Reporting Issues for more tips on writing good issues

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions