自动生成数据库模型和常见的 CRUD 操作
Usage
go run cmd/gormgen/main.go -h
Usage of ./cmd/gormgen/main.go:
-dsn string
consult[https://gorm.io/docs/connecting_to_the_database.html]
-tables string
enter the required data table or leave it blank
-dsn
用于连接数据库的DSN reference: https://gorm.io/docs/connecting_to_the_database.html
-tables
指定要生成的表名称,默认所有表。
eg :
--tables="orders" # generate from `orders`
--tables="orders,users" # generate from `orders` and `users`
--tables="" # generate from all tables
示例
# 根目录下执行
go run cmd/gormgen/main.go -dsn "root:api2api..@tcp(sh-cynosdbmysql-grp-88th45wy.sql.tencentcdb.com:28555)/bindbox_game?charset=utf8mb4&parseTime=True&loc=Local" -tables "admin,log_operation,log_request,activities,activity_categories,activity_draw_logs,activity_issues,activity_reward_settings,system_coupons,user_coupons,user_inventory,user_inventory_transfers,user_points,user_points_ledger,users,user_addresses,menu_actions,menus,role_actions,role_menus,role_users,roles,order_items,orders,products,shipping_records,product_categories,user_invites,system_item_cards,user_item_cards,activity_draw_effects,banner,activity_draw_receipts,system_titles,system_title_effects,user_titles,user_title_effect_claims,payment_preorders,payment_transactions,payment_refunds,payment_notify_events,payment_bills,payment_bill_diff,ops_shipping_stats,system_configs,issue_position_claims,task_center_tasks,task_center_task_tiers,task_center_task_rewards,order_coupons,matching_card_types,channels,user_game_tickets,game_ticket_logs,order_snapshots,audit_rollback_logs,user_coupon_ledger,user_game_passes,game_pass_packages"