Skip to content

Commit e9feb21

Browse files
authored
frontend query in create block (#612)
1 parent e9f241e commit e9feb21

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

apps/roam/src/utils/createReifiedBlock.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,11 @@ const strictQueryForReifiedBlocks = async (
2020
const query = `[:find ?u ?d
2121
:in $ ${paramsAsSeq.map(([k]) => "?" + k).join(" ")}
2222
:where [?s :block/uid ?u] [?s :block/props ?p] [(get ?p :${DISCOURSE_GRAPH_PROP_NAME}) ?d]
23-
${paramsAsSeq.map(([k]) => `[(get ?d :${k}) ?_${k}] [(= ?${k} ?_${k})]`).join(" ")} ]`;
24-
// Note: the extra _k binding variable is only needed for the backend query somehow
25-
// In a local query, we can directly map to `[(get ?d :${k}) ?${k}]`
26-
const result = await Promise.resolve(
27-
window.roamAlphaAPI.data.backend.q(
28-
query,
29-
...paramsAsSeq.map(([, v]) => v),
30-
) as [string, Record<string, string>][],
31-
);
23+
${paramsAsSeq.map(([k]) => `[(get ?d :${k}) ?${k}]`).join(" ")} ]`;
24+
const result = (await window.roamAlphaAPI.data.async.q(
25+
query,
26+
...paramsAsSeq.map(([, v]) => v),
27+
)) as [string, Record<string, string>][];
3228
// post-filtering because cannot filter by number of keys in datascript
3329
const numParams = Object.keys(parameterUids).length;
3430
const resultF = result

0 commit comments

Comments
 (0)