A blog's repository
Build the data functions a blog's pages call: the feed, tag pages, writing a post with tags, and publishing.
A data layer of small functions
This project brings the relations unit together. Every function uses at least one idea from it — relation filters, nested writes, connectOrCreate or include — so finishing it is good evidence you've understood how Prisma models connected data.
Pages shouldn't build Prisma queries themselves. Instead, write a small data layer: one function per need, each with a clear name and return type. The feed page calls feed(), the tag page calls tagged(name), the editor calls writePost(...). When a query changes, you change one function, and every page keeps working.
- feed() — published posts, newest first, with author names.
- tagged(name) — post titles filtered through the PostTag join model.
- writePost(authorId, title, tags) — a nested create with connectOrCreate tags.
- publish(id) — flip a flag; throw a clear error if the post doesn't exist.
Return plain, page-ready values (like formatted strings or small objects) rather than raw records with every field.