import { useLiveQuery } from "dexie-react-hooks"; import { database, ItemNotFoundError } from "../model"; export function useExpressionById(expression_id: number) { return useLiveQuery( () => database.expressions .where({ id: expression_id }) .toArray() .then((result) => { if (result.length === 0) return ItemNotFoundError; return result[0]; }), [expression_id] ); }