Todo Application — Aquilia Documentation
Comprehensive guide and documentation for Todo Application in the Aquilia framework. View API reference, examples, and implementation patterns.
Todo Application End-to-End Beginner-Level Tutorial with Code Examples In this tutorial, you will build a complete, database-backed REST API for a Todo application. You'll learn how to define database models using the Aquilia ORM, create request/response contracts using validation contracts, write business logic inside dependency-injected services, handle client errors using custom faults, and test your work using the built-in test client. ) })} , , , , , , ].map((item) => ( ))} )} language="python" filename="models.py" highlightLines= /> ORM Concept Explanations: • Model: The base class representing an ORM model. Metaclasses scan this subclass, build column registries, and attach a default objects Manager . • AutoField: Creates an autoincrementing integer primary key column. • BooleanField: A boolean field in SQL. Note that the contract validation counterpart is named BoolFacet , which handles type casting from JSON payloads. • class Meta: Metaclass metadata containing table settings, ordering rules (here we sort records in descending order of creation time), indexes, or custom database constraints. )} language="python" filename="services.py" highlightLines= /> DI and Query Concepts: • @service(scope="app"): Registers this service in the dependency injection container. "app" scope is initialized once and cached across requests. • TodoItem.objects: The QuerySet manager. We invoke all() to load all items, get(id=...) for single items, and create(**kwargs) to insert a new row in one command. • save(): An instance method on the model that compiles changed columns and executes an UPDATE SQL statement in the database. )} language="python" filename="controllers.py" highlightLines= /> Controller Route Concepts: • HTTP Verb Decorators: @GET , @POST , etc. bind route patterns to asynchronous handler methods. • request_contract: Enables automatic parsing of request bodies, casting inputs, and raising a SealFault if validation fails. The verified parameters are accessible via contract.validated_data. • response_contract: Filters and serializes model return values. We specify projections, e.g., TodoContract["summary"], to select which columns to output. • Path Parameters: Binds variables from URL paths (e.g. ) directly as type-coerced arguments in handler signatures. )} language="python" filename="test_todos.py" highlightLines= /> Running the Test Suite: Execute the tests using the aq test command: )} Previous Step Next Step )
Go to Homepage