This repository is focused on building an MVP todo app using EdgeDB, SVCS, and FastHTML.
module default {
type Todo {
required title: str {
constraint exclusive;
constraint min_len_value(1);
constraint max_len_value(50);
};
}
function select_todo_by_id(tid: uuid) -> Todo
using (
select (assert_exists(assert_single((select Todo filter .id=tid))))
)
}- Write EdgeQL queries and generate code using
edgedb-py(stick with version 1.9.0, as v2 may have compatibility issues). - Set up the
db_clientinlifespan.py. - Define the
dataclassmodels. - Implement the
__ft__()method for theTododataclass. - Use
svcs.starlette.aget()to obtain theAsyncIOClient. - Execute the generated queries to fetch results.
- Convert the results into
Todoinstances, which FastHTML recognizes as a type of FT component, utilizing the__ft__()method we defined. - Return the output as FT components.
- To get started, ensure
EdgeDBis set up and then runuvicorn app.main:app --port 8000 --reload.
