export const useBlock = (id: string) => {
const { blocks } = useCollections(); // defines all my collections
const query = useLiveQuery((q) =>
q
.from({ block: blocks })
.where(({ block }) => eq(block.id, id))
.findOne()
);
return {
block: query.data,
updateTitle: (title: string) =>
blocks.update(id, (draft) => {
draft.title = title;
}),
};
};
export const useBlock = (id: string) => {
const { blocks } = useCollections(); // defines all my collections
const query = useLiveQuery((q) =>
q
.from({ block: blocks })
.where(({ block }) => eq(block.id, id))
.findOne()
);
return {
block: query.data,
updateTitle: (title: string) =>
blocks.update(id, (draft) => {
draft.title = title;
}),
};
};