Database

CopyTyGo supports MySQL and PostgreSQL through database/sql. The query builder validates table and column identifiers and supported operators.

Connection#

DOTENV
DB_DRIVER=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=app
DB_USERNAME=app
DB_PASSWORD=your-local-password
BASH
ctg db:check
ctg migrate:status

For PostgreSQL, select the driver in the installer and configure the connection for your database.

Models and resources#

Data flow: handler → Context → database.Resource / model.Model → query builder → database. Relationship helpers include HasOne, HasMany, and BelongsTo. The framework also provides transactions, seeders, and factories.

BASH
ctg make:resource Product name:string price:decimal stock:integer active:boolean description:text?

The generator creates a model, database-backed controller, migration, validation, REST routes, timestamps, and soft deletes. Resources are private by default; install authentication and read the resource security guide.

Resource list queries#

TEXT
/products?page=2&per_page=20
/products?q=keyboard
/products?sort=price&order=desc
/products?filter[stock]=10

Search, filter, and sort use generated allowlists. Do not assume every column can be queried automatically.


Versioned sources v5.0.0: docs/ARCHITECTURE.md · docs/PRODUCTION.md · database/resource.go · README.md.

Search documentation

Type to search the documentation.