Skip to content

Commit

Permalink
chore: data service aggregate
Browse files Browse the repository at this point in the history
  • Loading branch information
nichenqin committed Dec 5, 2024
1 parent b59b0dd commit 52ac118
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import { TriangleAlertIcon } from "lucide-svelte"
import * as Tooltip from "$lib/components/ui/tooltip"
import type { TableDo } from "@undb/table"
import { getDataService, getIsLocal } from "$lib/store/data-service.store"
export let tableId: string | undefined
export let table: TableDo | undefined
Expand All @@ -19,10 +20,12 @@
$: isValid = isValidWidget(widget) && !!tableId
const isLocal = getIsLocal()
const getAggregate = createQuery({
queryKey: ["aggregate", widget.id],
enabled: !!tableId,
queryFn: () => {
queryFn: async () => {
const agg =
aggregate.type === "count"
? ({ [ID_TYPE]: "count" } as const)
Expand All @@ -37,7 +40,8 @@
ignoreView,
})
}
return trpc.record.aggregate.query({
const dataService = await getDataService(isLocal)
return dataService.records.getAggregates({
tableId: tableId!,
viewId,
aggregate: agg,
Expand Down

0 comments on commit 52ac118

Please sign in to comment.