I am very new to Dataview but see its power. I want to create a Data view that makes a Table of files. I would also like to be able to filter by requiring it to have the Tag SRD or the Line [[SRD]]
I don’t know why dataviewJS v DQL(honestly assuming this is Dataview Querry Language).
I am working on building a Dynamic D&D ruleset. I am using this to learn some of the deeper and nitty-gritty bits of dataview and obsidian. So honestly I don’t know the best solution.
It is not lost on me that I am green and asking for something very detailed. Maybe the better question is what are some of the best resources to learn where to start.
I know nothing about games (supposing Dynamic D&D is a game) and even less about “spells”.
You can start with this example:
```dataview
TABLE WITHOUT ID file.link as "spell", Components.Text as "Components", row["Casting Time"] AS "Casting Time", Concentration, choice(contains(row["Range Type"], "undefined"), Range, Range + row["Range Type"]) AS Range
FROM "your-folder-path"
```
Some notes:
your-folder-path means the path for the folder where you have your files (e.g. games/dd). It’s a filter to the sources. You can filter by a tag or nothing (not using FROM).
Dataview doesn’t like key fields as expressions (like Casting Time:). It’s more advised using something like CastingTime or casting-time, etc. Due to your use of expressions some fields not working in simple format (as Concentration) and requires the format row["<expression>"] (as row["Casting Time")… In conclusion, my suggestion is: don’t use expressions.
Read documentation and start playing with simple examples.
function toIST(num){
let arr = ["st","nd","rd","th"]
let suf
if(num >= 4){suf = arr[3]}else{suf = arr[num - 1]};
return num+suf
};
//Set up veriables
const startingSearch = '"050. Collections/Spell Book" and #SRD'
//Get all pages to get Classes from
const pages = dv.pages(startingSearch);
const classes = [];
//Creates a list of all Classes in the group of spells
for(const p of pages){
for(const c of p.Class){
if(classes.indexOf(c.path) < 0){classes.push(c.path)}
}
}
//Generates h3 Class H4 Spell Level and a table of spells in alfabetical order
for(const CLASS of classes){
let classHeading = CLASS + " Spells"
dv.header(3, classHeading);
let classSearch = startingSearch + " and [[" + CLASS + "]]"
for (let group of dv.pages(classSearch).groupBy(p => p.Level)) {
let header = group.key === 0 ? "Cantrip" : toIST(group.key) + " Level";
dv.header(4, header);
dv.table(["Spell","Casting Time","Duration","Components"],
group.rows
.sort(k => k.file.name, 'asc')
.map(k => [k.file.link, k["Casting Time"],k.Duration,k.Components.Text]))
}
}
Now finally we understand why you asked for JS (because you know well JS).
If you had shown something in your first post I would never have tried to answer because my js knowledge is almost zero (I understand some parts - related to dataview - but others no idea).