Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CLI] Generate Controller with CRUD methods #727

Closed
7 tasks done
kjdelisle opened this issue Nov 15, 2017 · 3 comments
Closed
7 tasks done

[CLI] Generate Controller with CRUD methods #727

kjdelisle opened this issue Nov 15, 2017 · 3 comments
Assignees
Labels
Milestone

Comments

@kjdelisle
Copy link
Contributor

kjdelisle commented Nov 15, 2017

Story

As a loopback4 user, I would like to run a CLI command to generate a default set of CRUD API methods based on a model and its associated datasource(s) so that I can avoid hand-writing each of these functions manually.

Acceptance Criteria

  • Prompt for controller name
  • Validate controller name
  • Prompt for whether or not they want to use the RestCrudController base template
  • If RestCrudController:
    • Generate new class that extends this type (should be a very small template!)
    async create(obj: T) : Promise<T>
    count(where: Where) : Promise<number>
    find(filter: Filter) : Promise<T[]>
    updateAll(where: Where, obj: T) : Promise<number>
    deleteAll(where: Where): Promise<number>

    findById(id: ID) :  Promise<T>
    updateById(id: ID, obj: T) :  Promise<boolean>
    deleteById(id: ID) :  Promise<boolean>
  • else
    • Fall back to generating an empty controller
  • Document this feature on loopback.io
  • Release the CLI package
  • Write a blog post about how awesome this new feature is and how to use it.
@kjdelisle kjdelisle changed the title [CLI] Generate CRUD methods based on legacy-juggler Models [CLI] Generate CRUD methods based on Models Dec 7, 2017
@kjdelisle kjdelisle changed the title [CLI] Generate CRUD methods based on Models [CLI] Generate Controller with CRUD methods Dec 7, 2017
@shimks shimks added planning and removed backlog labels Dec 8, 2017
@bajtos
Copy link
Member

bajtos commented Dec 12, 2017

As far as this story is concerned, it's ok return 200 from the create (POST) method (but see #788).

@kjdelisle
Copy link
Contributor Author

Blog post will go out on Thursday. Closing as complete.

@bajtos
Copy link
Member

bajtos commented Jan 23, 2018

@kjdelisle I just realised that our documentation added by loopbackio/loopback.io#583 is missing an important piece of information: how is the generator discovering models and repositories in the project? What conventions does it require to work correctly?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants