Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add inputs option to runQuery method #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

d4hines
Copy link

@d4hines d4hines commented Dec 8, 2021

Closes #16.

@d4hines
Copy link
Author

d4hines commented Dec 9, 2021

This doesn't work. It appears that closure variables aren't passed directly to the context that the callback is executed in. It also seems that roamAlphaAPI.q is variadic. So maybe the best thing to do is to overload this function - if query is a string, evaluate the query with roamAlphaAPI.q(query); but if query is an array, do roamAlphaAPI.q.apply(query).

EDIT: I tried this on an example query in the browser and got this error:

// example query
window.roamAlphaAPI.q.apply(null,[`[
  :find ?b
  :in $ ?target-date-title
  :where
  [?target-date :node/title ?target-date-title]
  [(ancestor ?b ?target-date)]
]`, targetDate, ancestorRule]);

// error
"Error: Extra inputs passed, expected: [$ ?target-date-title], got: 3
    at new <anonymous> (https://roamresearch.com/js/compiled/main.js?__WB_REVISION__=8bb0c07ce3839c921d406698a9df75d3:3831:193)
    at Function.zd (https://roamresearch.com/js/compiled/main.js?__WB_REVISION__=8bb0c07ce3839c921d406698a9df75d3:7250:325)
    at Function.xd (https://roamresearch.com/js/compiled/main.js?__WB_REVISION__=8bb0c07ce3839c921d406698a9df75d3:7250:277)
    at aua (https://roamresearch.com/js/compiled/main.js?__WB_REVISION__=8bb0c07ce3839c921d406698a9df75d3:4171:72)
    at Function.Ad (https://roamresearch.com/js/compiled/main.js?__WB_REVISION__=8bb0c07ce3839c921d406698a9df75d3:8395:191)
    at Function.Kd (https://roamresearch.com/js/compiled/main.js?__WB_REVISION__=8bb0c07ce3839c921d406698a9df75d3:8396:65)
    at Function.zd (https://roamresearch.com/js/compiled/main.js?__WB_REVISION__=8bb0c07ce3839c921d406698a9df75d3:6849:289)
    at Function.r4.Ad (/js/compiled/route-app.js:2236:311)
    at Function.r4.Kd (/js/compiled/route-app.js:2236:413)
    at Function.Dd (https://roamresearch.com/js/compiled/main.js?__WB_REVISION__=8bb0c07ce3839c921d406698a9df75d3:6849:428)
    at l (/js/compiled/route-app.js:1954:415)
    at k (/js/compiled/route-app.js:1954:369)
    at <anonymous>:1:23"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Missing option for inputs
1 participant