1 comment

[ 4.1 ms ] story [ 13.8 ms ] thread
TL;DR if you have a SQLite DB containing this table

    CREATE TABLE todo (
        id INTEGER PRIMARY KEY,
        description TEXT,
        done BOOLEAN
    )
This macro queries the DB during compilation and generates functions such as `todo-description` to work with queried rows from this table easily.

This means its a static error if you mistype the column name, for example. And no need to generate the DB from Lisp; you could setup the DB using manual DDL, rails, or even import a CSV to SQLite, etc. (Also, no reason why this couldn't work for a JSON file, API call, OpenAPI spec, etc.)

This article breaks down how that macro works, since it was pretty hard for me to learn it.

If one more person gets hooked on macros from this article, I will be so psyched! Happy to hear about any other cool macros or explain anything further here too.