Dataview list all notes cited in a document with some specific metadata

I have no idea how to do that because I am not very familiar with Dataview, but I am making some notes in a document and referencing other notes that contain metadata for a complete reference.

For instance, I have a note that is a scientific article (John Doe - 2023) and the yaml header of it has

---
citation: Doe, John. Journal of Something. 2023.
---

Then I have another note that I do

[[John Doe - 2023]] did something.

I want to build a reference section in my note with all citations from the document.
I know that backlinks kind of do that, but as I want to export this to a pdf and I want to show some particular metadata from the referenced notes, I’d prefer using Dataview.

1 | Doe, John. Journal of Something. 2023.

Topic

Summary
  • How to list all notes cited in a document with some specific metadata?

Test

Summary
  • dataview: v0.5.55

Input

Summary

the current note

  • Location: “100_Project/01_dataviewjs/01_by_example/Q30_Citation/Q30_test_data/10_Meeting”
  • filename : 20230225_mentions
```md
## Q30_Citation: using file.outlinks


### Mentions
[[John Doe - 2023]] did something.


### Q30_DVJS10 (OR Q30_DQL01)


```

dictionary files

  • Location: “100_Project/01_dataviewjs/01_by_example/Q30_Citation/Q30_test_data/20_Persons”

folder: 03_a_list_of_strings

  • filename : John Doe - 2023
```yaml
---
Date: 1961-03-01

citation: 
  - Doe, John. Journal of Something. 2023.
  - Doe, John. There is something more. 2023.
---
#Project/P03

```

folder: 04_a_string

  • filename : Tom Felton - 2023
```yaml
---
Date: 1961-04-01

citation: Felton, Tom. There is something more. 2023.
---
#Project/P04

```

DQL01_pull_person_note_metadata_into_meeting_note_by_using_file.outlinks

Summary

Main DQL

Code Name Data type Group By Purposes Remark
DQL01
_pull_person_note_metadata
_into_meeting_note
_by_using_file.outlinks
(Meeting notes)
this.file.outlinks:
a list of links

(Person notes)
citation:
1.a string
2.a list of strings
no 1.To break up a list this.file.outlinks into each individual element Person
1.1 this.file.outlinks: a list of links
1.2 Person: a link

2.To filter by Person.citation
3.To break up a list Person.citation into each individual element C
4.To display the result as a table

Code DQL01_pull_person_note_metadata_into_meeting_note_by_using_file.outlinks

Summary_code
title: DQL01_pull_person_note_metadata_into_meeting_note_by_using_file.outlinks =>1.To break up a list `this.file.outlinks` into each individual element `Person` 1.1 `this.file.outlinks`: a list of links 1.2 `Person`: a link 2.To filter by `Person.citation` 3.To break up a list `Person.citation` into each individual element `C` 4.To display the result as a table
collapse: close
icon: 
color: 
```dataview
TABLE WITHOUT ID
      Person AS "person",
      C AS "citation"

FROM "100_Project/01_dataviewjs/01_by_example/Q30_Citation/Q30_test_data/10_Meeting/20230225_mentions.md"

FLATTEN this.file.outlinks AS Person

WHERE Person.citation
FLATTEN Person.citation AS C

```

Screenshots(DQL01)


DVJS10_reuse_Q30_DQL01a_and_alter_original_result

Summary

Main DVJS

Code Name Data type Group By Purposes Remark
DVJS10
_reuse_Q30_DQL01a
_and
_alter_original_result
(Meeting notes)
this.file.outlinks:
a list of links

(Person notes)
citation:
a list of strings
no 1.To reuse the Q30_DQL01a
2.To alter the original result of the Q30_DQL01a

Code DVJS10_reuse_Q30_DQL01a_and_alter_original_result

Summary_code
title: DVJS10_reuse_Q30_DQL01a_and_alter_original_result => 1.To reuse the Q30_DQL01a 2.To alter the original result of the Q30_DQL01a
collapse: open
icon: 
color: 
```dataviewjs
// M10. define SourcePath: 
// #####################################################################
let SourcePath = dv.current().file.path;


// M11. define Q30_DQL01a: 
// #####################################################################
let Q30_DQL01a = `

TABLE WITHOUT ID
      Person AS "person",
      C AS "citation"

FROM "${SourcePath}"

FLATTEN this.file.outlinks AS Person

WHERE Person.citation
FLATTEN Person.citation AS C

`;


// M51. define h_result:
// run the Q30_DQL01a via dv.query and assign the result to h_result
// #####################################################################
let h_result = await dv.query(Q30_DQL01a);


// M52.debug output:
// #####################################################################
// dv.span(JSON.stringify(h_result, null, 2), "\n");

// {
//     value: {
//         type: "table",
//         values: [
//             [
//                 {
//                     path: "100_Project/01_dataviewjs/01_by_example/Q30_Citation/Q30_test_data/20_Persons/03/John Doe - 2023.md",
//                     type: "file",
//                     display: "John Doe - 2023",
//                     embed: false,
//                 },
//                 "Doe, John. Journal of Something. 2023.",
//             ],
//             [
//                 {
//                     path: "100_Project/01_dataviewjs/01_by_example/Q30_Citation/Q30_test_data/20_Persons/03/John Doe - 2023.md",
//                     type: "file",
//                     display: "John Doe - 2023",
//                     embed: false,
//                 },
//                 "Doe, John. There is something more. 2023.",
//             ],
//         ],
//         headers: ["person", "citation"],
//         idMeaning: {
//             type: "path",
//         },
//     },
//     successful: true,
// };



// dv.span(h_result.value.values[0]);
// [[John Doe - 2023]]
// Doe, John. Journal of Something. 2023.

// dv.span(h_result.value.values[0][1]);
// Doe, John. Journal of Something. 2023.

// dv.span("1 | " + h_result.value.values[0][1] + "<br>");
// 1 | Doe, John. Journal of Something. 2023.

// dv.span("2 | " + h_result.value.values[1][1] + "<br>");
// 2 | Doe, John. There is something more. 2023.


// M53. output h_result:
// #####################################################################
if (h_result.successful) {
    
    // Display the original data according to h_result.value.type
    switch (h_result.value.type) {
        case "table":
            // TABLE:
            //dv.table(h_result.value.headers, h_result.value.values);
            // M53.SW10 output "1 | " + h_result.value.values[0][1] + "<br>"
            // #########################################################
            for (let i = 0; i < h_result.value.values.length; i++) {
                let citation = h_result.value.values[i][1];
                let counter = i + 1;
                dv.span(counter + " | " + citation + "<br>");
            }

            break;
        case "list":
            // LIST:
            dv.list(h_result.value.values);
            break;
        case "task":
            // TASK:
            dv.taskList(h_result.value.values);
            break;
        case "calendar":
            // CALENDAR: run a Q30_DQL01a
            dv.execute(Q30_DQL01a);
            break;
        default:
            // do nothing
    }
    
} else {
    dv.span(h_result.error);
}


```

Screenshots(DVJS10)


Reference

Summary

Q23_meeting : DQL10

Q16_Links

Q78_MediumCat : mDVJS05

  • Q78_MediumCat:Part02

For those who are curious. Something like that might work.

```dataview
TABLE WITHOUT ID file.link.citation AS "Reference"
WHERE contains(this.file.outlinks, file.link)
```

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.