-
-
Notifications
You must be signed in to change notification settings - Fork 2
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
Add CLI questions to create model with attributes #8
Comments
hey, can you explain this a bit more? I'm interested |
Hey @meerhamzadev, this issue will add some questions to the CLI after choosing a framework to add an attribute to the CRUD. Example: Add attribute ? yes/no
-> yes
Attribute name:
-> email
Attribute type:
-> string
Attribute length:
-> 100
Attribute is required ? yes/no
-> yes
Attribute is unique ? yes/no
-> yes
Attribute "email" add successfully!
Add attribute ? yes/no
-> no
// Generate the files... |
So, I was supposed to provide the interface right? or functionality as well? |
You can help however you can. Count on me to help you with anything you need, I can help you with functionality and the CLI too. |
To facilitate this, we can make a brainstorm for what we will need to finalize this issue
Model// NestJS TypeORM Model example
import { Entity, Column, PrimaryGeneratedColumn } from 'typeorm'
export class <%= namePascal %> {
@PrimaryGeneratedColumn()
id: string
<% for (attribute of attributes) { %>
@Column({
unique: <%= attribute.unique %>,
length: <%= attribute.length %>,
nullable: <%= !attribute.required %>,
})
<%= attribute.name %>: <%= attribute.type %>;
<% } %>
@CreateDateColumn({ name: 'created_at' })
createdAt: Date
@UpdateDateColumn({ name: 'updated_at' })
updatedAt: Date
@Column({ name: 'deleted_at' })
deletedAt?: Date
@Column({ enum: ['pendent', 'active'] })
status: string
/**
* Relations
*/
} Validator// NestJS TypeORM Validator example
import { Injectable } from '@nestjs/common'
import { Validator } from '@secjs/validator'
@Injectable()
export class <%= namePascal %>Validator extends Validator {
get schema() {
return {
<% for (attribute of attributes) { %>
<%= attribute.name %>: '<%= attribute.required ? 'required' : '' %>|<%= attribute.unique ? 'unique:<%= namePlural %>' : '' %>';
<% } %>
}
}
} These are just examples, I didn't test it, but I think that should work.
|
Ok, I would give it a try, this weekend 🙌 |
hey, @jlenon7 how to run CLI locally? |
Hey @meerhamzadev, sorry about that, I will document how to run locally later.
npm install -g yo
npm install
npm link
yo secjs Foo --path=./Bar |
No description provided.
The text was updated successfully, but these errors were encountered: