-
Hello, I would like to use dataviewJS to track:
BackgroundBelow an example of a storage box note (name and YAML) as well as a set of object notes that use it. Storage boxfilename: box-1
Where object being storedLet's say I have two of these objects (notes), with the following metadata: filename: shoes
filename: clothes
If I run the following DQL query,
It (correctly) returns the list:
Because "clothes" is empty. However, if I now try to write the following in box-1: Spaces available: I run into issues with the "Remaining" code. Things I have triedBasic dataviewJS variant: This returns 4 (from Using
Which should return 1 but instead fails with I have also tried (credit to holroy):
Which returns QuestionI feel (perhaps erroneously) that I am new to JS. Is there a simple formatting issue that I am missing? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Got this working based on @blacksmithgu's response to this thread in 2022. It turns out I had made a few errors:
With these changes, the following query returns
And the final query:
Correctly returns 3. |
Beta Was this translation helpful? Give feedback.
Got this working based on @blacksmithgu's response to this thread in 2022. It turns out I had made a few errors:
dv.func
does not need to be wrapped inside a{return}
for this purposedv.fileLink
that checks for file names in metadataWith these changes, the following query returns
1
:$=dv.pages('#stuff').where(p => dv.func.contains(p.stored_in, dv.fileLink("box-1"))).length
And the final query:
$=dv.current().this_boxes_available - dv.pages('#stuff').where(p => dv.func.contains(p.stored_in, dv.fileLink("box-1"))).length
Correctly returns 3.