Skip to content

Dataview Queries

Obsidian Dataview lets you query wiki pages by frontmatter fields. Install it from Community plugins and enable JavaScript Queries in its settings.

TABLE source-type AS "Type", author AS "Author",
date-created AS "Added", join(domain, ", ") AS "Domain"
FROM "wiki/sources"
SORT date-created DESC
TABLE entity-type AS "Type", join(aliases, ", ") AS "Aliases",
join(domain, ", ") AS "Domain", length(file.inlinks) AS "Referenced By"
FROM "wiki/entities"
SORT entity-type ASC, file.name ASC
TABLE join(domain, ", ") AS "Domain", join(tags, ", ") AS "Tags",
date-modified AS "Last Updated", length(file.inlinks) AS "Referenced By"
FROM "wiki/concepts"
SORT domain ASC, file.name ASC
TABLE page-type AS "Type", join(domain, ", ") AS "Domain",
date-modified AS "Modified"
FROM "wiki"
WHERE page-type
SORT date-modified DESC
LIMIT 20
TABLE page-type AS "Type", date-created AS "Created"
FROM "wiki"
WHERE page-type AND (!sources OR length(sources) = 0)
SORT date-created DESC
TABLE page-type AS "Type", date-created AS "Created"
FROM "wiki"
WHERE page-type AND length(file.inlinks) = 0
SORT date-created DESC

Create a wiki/dashboard.md page with inline stats and tables:

## Stats
- Total pages: `$= dv.pages('"wiki"').where(p => p["page-type"]).length`
- Sources: `$= dv.pages('"wiki/sources"').length`
- Entities: `$= dv.pages('"wiki/entities"').length`
- Concepts: `$= dv.pages('"wiki/concepts"').length`
- Comparisons: `$= dv.pages('"wiki/comparisons"').length`

Add the “Recently Modified” and “Most Connected” queries from above for a complete overview.

const pages = dv.pages('"wiki"').where(p => p["page-type"]);
const domains = {};
pages.forEach(p => {
const d = p.domain;
if (d) {
(Array.isArray(d) ? d : [d]).forEach(tag => {
domains[tag] = (domains[tag] || 0) + 1;
});
}
});
const sorted = Object.entries(domains).sort((a, b) => b[1] - a[1]);
dv.table(["Domain", "Pages"], sorted.map(([d, c]) => [d, c]));
const entities = dv.pages('"wiki/entities"');
const rows = [];
entities.forEach(e => {
const inlinks = e.file.inlinks;
const sourceLinks = inlinks.filter(l => l.path.includes("sources/"));
rows.push([e.file.link, e["entity-type"] || "-", sourceLinks.length, sourceLinks.join(", ")]);
});
rows.sort((a, b) => b[2] - a[2]);
dv.table(["Entity", "Type", "# Sources", "Mentioned In"], rows);
FieldAll PagesType-Specific
titleyes
date-createdyes
date-modifiedyes
page-typeyes
domainyes (list)
tagsyes (list)
sourcesyes (list)
relatedyes (list)
source-urlsource-note
source-typesource-note
authorsource-note
date-accessedsource-note
raw-filesource-note
entity-typeentity
aliasesentity (list)
promoted-frompromoted pages