From a4d5da79dc32876188aefbc0a2801cc86a4f3835 Mon Sep 17 00:00:00 2001 From: Ivan S Glazunov Date: Mon, 26 Jun 2023 11:00:36 +0000 Subject: [PATCH] useDeepId and debug useDeepQ/S --- imports/client.tsx | 7 +++++++ package.json | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/imports/client.tsx b/imports/client.tsx index 2987b21b..825babe5 100644 --- a/imports/client.tsx +++ b/imports/client.tsx @@ -1086,6 +1086,7 @@ export function useDeepQuery { const sq = serializeQuery(query); @@ -1125,6 +1126,7 @@ export function useDeepSubscription
{ const [miniName] = useState(options?.mini || Math.random().toString(36).slice(2, 7)); + debug('useDeepSubscription', miniName, query, options); const deep = useDeep(); const wq = useMemo(() => { const sq = serializeQuery(query); @@ -1158,4 +1160,9 @@ export interface UseDeepSubscriptionResult> { data?: LL[]; error?: any; loading: boolean; +} + +export function useDeepId(start: DeepClientStartItem | QueryLink, ...path: DeepClientPathItem[]): { data: number; loading: boolean; error?: any } { + const result = useDeepQuery({ id: { _id: [start, ...path] } }); + return { data: result?.data?.[0]?.id, loading: result?.loading, error: result?.error }; } \ No newline at end of file diff --git a/package.json b/package.json index 7303630d..725fbfcf 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@deep-foundation/deeplinks", - "version": "0.0.196", + "version": "0.0.197", "license": "Unlicense", "type": "module", "scripts": {