#Feedback on TS function

3 messages · Page 1 of 1 (latest)

vital robin
#

How could the following function be improved? I'm using the Prisma client as DB.

I'm learning TS at the moment and looking for feedback.

const all = async (): Promise<Task[]> => {
    try {
        const tasks: Task[] = await DB.tasks.findMany()
        return tasks;
    } catch (err) {
        console.error(err)
        return []
    }
}
tribal abyss
#

I don't know if findMany can throw

#

which means this code is _effectively const all = DB.tasks.findMany