-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Description
Description / Feature proposal
CLI command to generate model TS file.
- The prompt asks:
- name of the model
- property name and type (repeating till user enter empty name for property name)
- The generated model.ts would look something like: https://github.com/strongloop/loopback-next/blob/0411811aa8348e31636fb0fe07b44dd18469280f/examples/todo/src/models/todo.model.ts
Outstanding questions
- Do we ask the user to select the base class? If yes, what are the selections? or it will always be
Entity. - What are the property types we support? Here is what we have in LB3:
string
number
boolean
object
array
date
buffer
Acceptance Criteria
- Make a CLI prompt for model and its properties
- For properties, ask for their name, their types and their default values
- The produced model should extend from
Entity
User Experience
$ lb4 model
? Enter the model name: Customer
Let's add some Customer properties now.
Enter an empty property name when done.
? Property name: customerId
? Property type: (show a list of available types) string
? Required? (y/N) y
? Default value[leave blank for none]:
Let's add another Customer property.
Enter an empty property name when done.
? Property name: name
? Property type: (show a list of available types) string
? Required? (y/N) y
? Default value[leave blank for none]:
At the end, src/models/customer.model.ts will be created.
Reactions are currently unavailable