Comment

Comment by zemo

usually for stores like this I just do this:

    type Store interface {
        GetTask(*Task) error
    }
instead of having "GetTaskByID" and "GetTaskByTag" and whatnot. Then in the caller you just do this:

    task := store.Task{ID: 5}
    if err := db.GetTask(&task); err != nil {
        // wahtever
    }
^ that gets the task by ID

    task := store.Task{Tag: "foo"}
    if err := db.GetTask(&task); err != nil {
        // wahtever
    }
^ that gets the task by tag.
parent zemo 5 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton