File: zzMeta/dv/GalleryDQL
I placed the query in the filename given above, so that it would appear at the bottom of your vault. This can of course be changed to whatever you feel like, and itโs content are as follows:
TABLE without id
("") AS "Cover",
P_BookByAuthor + P_MediumIcon + P_FavoriteIcon AS "Title",
Q_YearRating + Q_PagesHours + " || " + Q_FLAG AS "Time and Place",
R_Dates AS "Dates",
"(" + S_ReadingTime + " || " + S_ReadingSpeed + ")" AS "Reading Time"
FROM "Book Log" OR "Y Movies and Games" OR "0 Currently Reading" OR "Set Aside"
WHERE filter(choice(typeof(country) = "array", country, list(country)),
(c) => meta(c).path = this.file.path)
FLATTEN array( {
"Book": Author,
"Audiobook": Author,
"Podcast": Author,
"eBook": Author,
"AcademicBook": Author,
"AcademicArticle": Author,
"GraphicNovel": Author,
"Movie": Director,
"TV": Director,
"Game": Director
}[Medium] ) AS Creator
FLATTEN link(file.link, Alias) + " by " + Creator AS P_BookByAuthor
FLATTEN choice(contains(tags, "Favorite"), "๐", "") AS P_FavoriteIcon
SORT DateFinished desc
FLATTEN {
"Book": " ๐ ",
"Audiobook": " ๐ง ",
"Podcast": " ๐ป ",
"eBook": " ๐ ",
"AcademicBook": " ๐๐ ",
"AcademicArticle": " ๐ฐ ",
"GraphicNovel": " ๐ฌ ",
"Movie": " ๐๏ธ ",
"TV": " ๐บ ",
"Game": " ๐ฎ "
}[Medium] AS P_MediumIcon
FLATTEN DateStarted + " โ " + DateFinished AS R_Dates
FLATTEN choice(((DateFinished - DateStarted).days = 1), "1 day", choice((DateFinished != DateStarted), (DateFinished - DateStarted).days + " days", "0 days" )) AS S_ReadingTime
FLATTEN {
"Book": round(choice((DateFinished = DateStarted), Length, (Length / (DateFinished - DateStarted).days)), 1) + " p/d",
"Audiobook": round(choice((DateFinished = DateStarted), Length, (Length / (DateFinished - DateStarted).days)), 2) + " h/d",
"Podcast": round(choice((DateFinished = DateStarted), Length, (Length / (DateFinished - DateStarted).days)), 2)+ " h/d",
"eBook": round(choice((DateFinished = DateStarted), Length, (Length / (DateFinished - DateStarted).days)), 1) + " p/d",
"GraphicNovel": round(choice((DateFinished = DateStarted), Length, (Length / (DateFinished - DateStarted).days)), 1) + " p/d",
"AcademicBook": round(choice((DateFinished = DateStarted), Length, (Length / (DateFinished - DateStarted).days)), 1) + " p/d",
"AcademicArticle": round(choice((DateFinished = DateStarted), Length, (Length / (DateFinished - DateStarted).days)), 1) + " p/d",
"Movie": round(choice((DateFinished = DateStarted), round((Length/60), 1), (Length / (DateFinished - DateStarted).days)), 1) + " h/d",
"TV": round(choice((DateFinished = DateStarted), round((Length/60), 1), (Length / (DateFinished - DateStarted).days)), 1) + " h/d",
"Game": round(choice((DateFinished = DateStarted), round((Length/60), 1), (Length / (DateFinished - DateStarted).days)), 1) + " h/d"
}[Medium] AS S_ReadingSpeed
FLATTEN Year + " || " + " โญ " + Rating + " || " AS Q_YearRating
FLATTEN {
"Book": Length + " p",
"Audiobook": Length + " h",
"Podcast": Length + " h",
"eBook": Length + " p",
"GraphicNovel": Length + " p",
"AcademicBook": Length + " p",
"AcademicArticle": Length + " p",
"Movie": round((Length/60), 1) + " h",
"TV": round((Length/60), 1) + " h",
"Game": round((Length/60), 1) + " h"
}[Medium] AS Q_PagesHours
FLATTEN join(map(choice(typeof(Country) = "array", Country, list(Country)), (c) => link(
meta(c).path, {
AD: "๐ฆ๐ฉ", AE: "๐ฆ๐ช", AF: "๐ฆ๐ซ", AG: "๐ฆ๐ฌ", AI: "๐ฆ๐ฎ", AL: "๐ฆ๐ฑ", AM: "๐ฆ๐ฒ", AO: "๐ฆ๐ด", AQ: "๐ฆ๐ถ", AR: "๐ฆ๐ท", AS: "๐ฆ๐ธ", AT: "๐ฆ๐น", AU: "๐ฆ๐บ", AW: "๐ฆ๐ผ", AX: "๐ฆ๐ฝ", AZ: "๐ฆ๐ฟ",
BA: "๐ง๐ฆ", BB: "๐ง๐ง", BD: "๐ง๐ฉ", BE: "๐ง๐ช", BF: "๐ง๐ซ", BG: "๐ง๐ฌ", BH: "๐ง๐ญ", BI: "๐ง๐ฎ", BJ: "๐ง๐ฏ", BL: "๐ง๐ฑ", BM: "๐ง๐ฒ", BN: "๐ง๐ณ", BO: "๐ง๐ด", BQ: "๐ง๐ถ", BR: "๐ง๐ท", BS: "๐ง๐ธ", BT: "๐ง๐น", BV: "๐ง๐ป", BW: "๐ง๐ผ", BY: "๐ง๐พ", BZ: "๐ง๐ฟ",
CA: "๐จ๐ฆ", CC: "๐จ๐จ", CD: "๐จ๐ฉ", CF: "๐จ๐ซ", CG: "๐จ๐ฌ", CH: "๐จ๐ญ", CI: "๐จ๐ฎ", CK: "๐จ๐ฐ", CL: "๐จ๐ฑ", CM: "๐จ๐ฒ", CN: "๐จ๐ณ", CO: "๐จ๐ด", CR: "๐จ๐ท", CU: "๐จ๐บ", CV: "๐จ๐ป", CW: "๐จ๐ผ", CX: "๐จ๐ฝ", CY: "๐จ๐พ", CYMRU: "๐ด๓ ง๓ ข๓ ท๓ ฌ๓ ณ๓ ฟ", CZ: "๐จ๐ฟ",
DE: "๐ฉ๐ช", DJ: "๐ฉ๐ฏ", DK: "๐ฉ๐ฐ", DM: "๐ฉ๐ฒ", DO: "๐ฉ๐ด", DZ: "๐ฉ๐ฟ",
EC: "๐ช๐จ", EE: "๐ช๐ช", EG: "๐ช๐ฌ", EH: "๐ช๐ญ", ENG: "๐ด๓ ง๓ ข๓ ฅ๓ ฎ๓ ง๓ ฟ", ER: "๐ช๐ท", ES: "๐ช๐ธ", ET: "๐ช๐น",
FI: "๐ซ๐ฎ", FJ: "๐ซ๐ฏ", FK: "๐ซ๐ฐ", FM: "๐ซ๐ฒ", FO: "๐ซ๐ด", FR: "๐ซ๐ท",
GA: "๐ฌ๐ฆ", GB: "๐ฌ๐ง", GD: "๐ฌ๐ฉ", GE: "๐ฌ๐ช", GF: "๐ฌ๐ซ", GG: "๐ฌ๐ฌ", GH: "๐ฌ๐ญ", GI: "๐ฌ๐ฎ", GL: "๐ฌ๐ฑ", GM: "๐ฌ๐ฒ", GN: "๐ฌ๐ณ", GP: "๐ฌ๐ต", GQ: "๐ฌ๐ถ", GR: "๐ฌ๐ท", GS: "๐ฌ๐ธ", GT: "๐ฌ๐น", GU: "๐ฌ๐บ",GW: "๐ฌ๐ผ", GY: "๐ฌ๐พ",
HK: "๐ญ๐ฐ", HM: "๐ญ๐ฒ", HN: "๐ญ๐ณ", HR: "๐ญ๐ท", HT: "๐ญ๐น", HU: "๐ญ๐บ",
ID: "๐ฎ๐ฉ", IE: "๐ฎ๐ช", IL: "๐ฎ๐ฑ", IM: "๐ฎ๐ฒ", IN: "๐ฎ๐ณ", IO: "๐ฎ๐ด", IQ: "๐ฎ๐ถ", IR: "๐ฎ๐ท", IS: "๐ฎ๐ธ", IT: "๐ฎ๐น",
JE: "๐ฏ๐ช", JM: "๐ฏ๐ฒ", JO: "๐ฏ๐ด", JP: "๐ฏ๐ต",
KE: "๐ฐ๐ช", KG: "๐ฐ๐ฌ", KH: "๐ฐ๐ญ", KI: "๐ฐ๐ฎ", KM: "๐ฐ๐ฒ", KN: "๐ฐ๐ณ", KP: "๐ฐ๐ต", KR: "๐ฐ๐ท", KW: "๐ฐ๐ผ", KY: "๐ฐ๐พ", KZ: "๐ฐ๐ฟ",
LA: "๐ฑ๐ฆ", LB: "๐ฑ๐ง", LC: "๐ฑ๐จ", LI: "๐ฑ๐ฎ", LK: "๐ฑ๐ฐ", LR: "๐ฑ๐ท", LS: "๐ฑ๐ธ", LT: "๐ฑ๐น", LU: "๐ฑ๐บ", LV: "๐ฑ๐ป", LY: "๐ฑ๐พ",
MA: "๐ฒ๐ฆ", MC: "๐ฒ๐จ", MD: "๐ฒ๐ฉ", ME: "๐ฒ๐ช", MF: "๐ฒ๐ซ", MG: "๐ฒ๐ฌ", MH: "๐ฒ๐ญ", MK: "๐ฒ๐ฐ", ML: "๐ฒ๐ฑ", MM: "๐ฒ๐ฒ", MN: "๐ฒ๐ณ", MO: "๐ฒ๐ด", MP: "๐ฒ๐ต", MQ: "๐ฒ๐ถ", MR: "๐ฒ๐ท", MS: "๐ฒ๐ธ", MT: "๐ฒ๐น", MU: "๐ฒ๐บ", MV: "๐ฒ๐ป", MW: "๐ฒ๐ผ", MX: "๐ฒ๐ฝ", MY: "๐ฒ๐พ", MZ: "๐ฒ๐ฟ",
NA: "๐ณ๐ฆ", NC: "๐ณ๐จ", NE: "๐ณ๐ช", NF: "๐ณ๐ซ", NG: "๐ณ๐ฌ", NI: "๐ณ๐ฎ", NL: "๐ณ๐ฑ", NO: "๐ณ๐ด", NP: "๐ณ๐ต", NR: "๐ณ๐ท", NU: "๐ณ๐บ", NZ: "๐ณ๐ฟ",
OM: "๐ด๐ฒ",
PA: "๐ต๐ฆ", PE: "๐ต๐ช", PF: "๐ต๐ซ", PG: "๐ต๐ฌ", PH: "๐ต๐ญ", PK: "๐ต๐ฐ", PL: "๐ต๐ฑ", PM: "๐ต๐ฒ", PN: "๐ต๐ณ", PR: "๐ต๐ท", PS: "๐ต๐ธ", PT: "๐ต๐น", PW: "๐ต๐ผ", PY: "๐ต๐พ",
QA: "๐ถ๐ฆ",
RE: "๐ท๐ช", RO: "๐ท๐ด", RS: "๐ท๐ธ", RU: "๐ท๐บ", RW: "๐ท๐ผ",
SA: "๐ธ๐ฆ", SB: "๐ธ๐ง", SC: "๐ธ๐จ", SCOT: "๐ด๓ ง๓ ข๓ ณ๓ ฃ๓ ด๓ ฟ", SD: "๐ธ๐ฉ", SE: "๐ธ๐ช", SG: "๐ธ๐ฌ", SH: "๐ธ๐ญ", SI: "๐ธ๐ฎ", SJ: "๐ธ๐ฏ", SK: "๐ธ๐ฐ", SL: "๐ธ๐ฑ", SM: "๐ธ๐ฒ", SN: "๐ธ๐ณ", SO: "๐ธ๐ด", SR: "๐ธ๐ท", SS: "๐ธ๐ธ", ST: "๐ธ๐น", SV: "๐ธ๐ป", SX: "๐ธ๐ฝ", SY: "๐ธ๐พ", SZ: "๐ธ๐ฟ",
TC: "๐น๐จ", TD: "๐น๐ฉ", TF: "๐น๐ซ", TG: "๐น๐ฌ", TH: "๐น๐ญ", TJ: "๐น๐ฏ", TK: "๐น๐ฐ", TL: "๐น๐ฑ", TM: "๐น๐ฒ", TN:"๐น๐ณ", TO: "๐น๐ด", TR: "๐น๐ท", TT: "๐น๐น", TV: "๐น๐ป", TW: "๐น๐ผ", TZ: "๐น๐ฟ",
UA: "๐บ๐ฆ", UG: "๐บ๐ฌ", UM: "๐บ๐ฒ", US: "๐บ๐ธ", UY: "๐บ๐พ", UZ: "๐บ๐ฟ",
VA: "๐ป๐ฆ", VC: "๐ป๐จ", VE: "๐ป๐ช", VG: "๐ป๐ฌ", VI: "๐ป๐ฎ", VN: "๐ป๐ณ", VU: "๐ป๐บ",
WF: "๐ผ๐ซ", WS: "๐ผ๐ธ",
YE: "๐พ๐ช", YT: "๐พ๐น",
ZA: "๐ฟ๐ฆ", ZM: "๐ฟ๐ฒ", ZW: "๐ฟ๐ผ"
}[meta(c).display]
)), ", ") AS Q_FLAG
Notice how it lists both of the creators of โJohn Wickโ, and lists multiple countries for all the books.
For United Kingdom, it includes both the โJohn Wickโ and the โThe Audiobook of the Year 2018โ.
Iโve focused here on just this one DQL query, but it could be considered useful to split that query into multiple parts. For example one could argue the case that the definition of the Q_FLAG
should be considered a separate query, as one can easily see it reused in other queries.
This syntax allows for using different parts as building bricks of your query, but it doesnโt allow for anything to be changed within one of the parts. It could still be useful when dealing with vaults like yours since the metadata structure is somewhat fixed.
Two other variations does although exist, having the โmain queryโ as text inline and then bits and pieces in query part notes, and to use dv.view()
and allow for the parts to be modified like with different column names, and stuff like that. Iโm not going to cover that last part here, but Iโm going to show a variant of the first suggestion here:
That last part could be written in various different ways, here is one which includes a โrandomโ sorting line in the midst of the various parts:
What goes in which part and so on, depends on which part of your queries varies, and what makes sense for you to include in various queries.
The advantage of this latter variant, is that it allowsfor the main part of the query to be seen without needing to look into other files, whilst still keeping the bulk of the query in imported files.
The overall advantage of having either part or the entire query in separate files, is that then you need only to update one (or a few) query parts when something changes. And you donโt need to go into all of the country files (for example) to update your queries.