CRUD Command

The crud command generates basic CRUD (Create, Read, Update, Delete) operations for your zopio project. This command creates the necessary files for handling data operations in your application.

Usage

zopio crud [options]

Options

OptionDescription
-m, --model <name>Model name for CRUD operations
-f, --fields <fields>Fields in format “name:type,age:number”
-o, --output <directory>Output directory for generated files
-h, --helpDisplay help for command

Examples

Generate CRUD operations for a User model

zopio crud --model User --fields "name:string,email:string,age:number,isActive:boolean"

Generate CRUD operations with a custom output directory

zopio crud --model Product --fields "name:string,price:number,description:string,inStock:boolean" --output src/modules/products

Generated Files

When you run the crud command, the following files will be generated:

  1. Controller: Handles HTTP requests and responses
  2. Service: Contains business logic for CRUD operations
  3. Repository: Interacts with the database
  4. Routes: Defines API endpoints for CRUD operations
  5. Model: Defines the data structure

For more specialized CRUD generation, you can use these related commands: