DataviewJS Snippet Showcase

Question

What :: DataviewJS By Example Q181
fromURL :: patrick_ambrosso: DataviewJS Snippet Showcase Q181

Question :: How to get the number of orphan notes?

Answer :: See Code T06_A first.
WebUpdatedOn :: 2022-06-25
KeyClasses :: DataviewJS
toURL :: Solutions

Test06: Get the number of orphan notes(Tagged: Habit )

Inline DataviewJS Queries

ONLY for Inline Queries

T06_A_the number of orphan notes: $=dv.pages("#Habit").where((page)=>page.file.inlinks.length===0&&page.file.outlinks.length===0).file.name.length

  • Here is the output(non-HTML).
5
The following also can be executed within a DataviewJS block
  • dv.span() or dv.list() may be omitted in Inline DataviewJS Queries.

T06_B_the number of orphan notes: $=dv.span(dv.pages("#Habit").where((page)=>page.file.inlinks.length===0&&page.file.outlinks.length===0).file.name.length)

  • Here is the output(non-HTML).
5
DataviewJS block

T06_C_the number of orphan notes:

dv.span(
    dv
        .pages("#Habit")
        .where(
            (page) =>
                page.file.inlinks.length === 0 &&
                page.file.outlinks.length === 0
        ).file.name.length
);
  • Here is the output(non-HTML).
5
1 Like