I am new to dataview, and I am just trying to build a database of quotes.
Since I would like the entire text of the actual quote to be displayed in my dataview queries, I simply put the quote directly into the front matter, under the property “quote-text”. (I use a css snippet to get it to wrap.)
It works fine, with the 60 or so quotes I have put in so far.
My question is:
Is having hundreds and hundreds of empty notes with quotes in their metadata a reasonable approach?
Can it be scaled up performantly, to say, a few thousand quotes? Does having rather big values in fields bog down dataview?
Am I right in assuming that there is no way to do this with the text in the actual note, rather than the metadata, since dataview can only read frontmatter, inline fields and, apparently, also lists?
Is there a better way?
How would you do this?
(Pictures show a query, and the template I use. I have ratings as a list properties, in case I should want to include other people’s ratings in the future.)
Why not use inline fields? That’s what I do with mine, including the quote within my journals. This allows me to go back to the journal and see the quote in context (surrounding text might be related). >Quote:: I sleep like a baby. I wake up screaming every morning around 3am. -- Tommy Cooper
I already have quite a few properties (and planning to add at least one more), that I want to use for searching, and that I want to create consistently, by using a template.
I would develop the system in such a way that a note could hold multiple quotes and it would still work. I personally have a lot of types of structured data that work in this way, and it’s a good trade-off generally, if you don’t mind a lot of yaml
I don’t know how I would go about creating yaml of this type, since I thought having the text in the metadata is the only way to display it in my queries.
Do your queries display the quotes?
Or is that not so important to you, or maybe you do it some other way, like by control hovering over a link?
here’s an example piece of yaml from my file on the film “Casablanca”:
credit:
- name: Michael Curtiz
role: director
- name: Humphrey Bogart
character: Rick Blaine
role: actor
- name: Ingrid Bergman
character: Ilsa Lund
role: actor
- name: Paul Henried
character: Victor Laszlo
role: actor
- name: Claude Rains
character: Captain Louis Renault
role: actor
- name: Conrad Veidt
character: Major Heinrich Strasser
role: actor
- name: Sydney Greenstreet
character: Signor Ferrari
role: actor
- name: Peter Lorre
character: Ugarte
role: actor
- name: Dooley Wilson
character: Sam
role: actor
- name: Julius J. Epstein
role: writer
- name: Philip G. Epstein
role: writer
- name: Howard Koch
role: writer
- name: Murray Burnett
role: source writer
- name: Joan Alison
role: source writer
- name: Jack L. Warner
role: executive producer
- name: Arthur Edeson
role: cinematographer
- name: Max Steiner
role: composer
- name: Owen Marks
role: film editor
=this.credit.name gives me a list of everyone who worked on it.
Meanwhile I have a [[Humphrey Bogart]] file with this in it:
TABLE Q.role as role
FROM #media
WHERE contains(credit.name,this.file.name)
FLATTEN credit AS Q
WHERE contains(Q.name,this.file.name)
LIMIT 100
Which gives me a table of films he worked on and his role.
With this example you may be able to adapt the concepts to your use case.
Maybe you collect quotes by the same person in the same file, or you include the author in the metadata and collect quotes by month or arbitrarily…
Of course nothing stops you from doing a file per quote but it isn’t the only way.
I wanted to put my take on this question, and that is in general I tend not to use the frontmatter for any of the “vital” data present in that note. Or put another way, I wouldn’t place the quote within the frontmatter if that’s the crucial part. I would only put actual metadata related to the quote in the frontmatter.
Along the same kind of reasoning, I’m placing my quotes in tasks throughout the documents, and if need be I can pull out any relevant metadata from the frontmatter. So given an example of some random book, I could possibly have a note like:
---
type: book
title: "My glorious book"
author: myself
---
Something about the book
- [q] I'm quoting myself
... more text ...
- [q] Another genius quote
Which with a little styling looks like:
And some various ways to extract these quotes:
## Pure quotes
```dataview
TASK
WHERE file.folder = this.file.folder
AND status = "q"
```
## Grouped by file with author
```dataview
TASK
WHERE file.folder = this.file.folder
FLATTEN text + " (" + author + ")" as visual
GROUP BY file.link
```
## Quotes with links added to the text
```dataview
TASK
WHERE file.folder = this.file.folder
AND status = "q"
FLATTEN text + ", " + file.link as visual
```
Do note that the last example is kind of superfluous, since by nature all task queries link back to their origin, which is an advantage in my book.
The FLATTEN ... as visual trick can also be used to remove any inline fields defined in the task if one chooses that approach to add extra information to a particular quote without needing to display those fields. My train of thoughts is that in most cases, the metadata on the note is adequate for the quote in itself, but you could specify some extra if need be.
In summary I like this style of defining the quotes since it looks nice in the context where I define them, and it allows for easy retrieval in queries. And through the use of FLATTEN ... as visual I can change the output of the task to whatever I’d like and still keep the link back to where it was written. This can also be used to remove inline fields, if one wanted to use that for extra information related to the quotes.
Using the method @holroy suggested works great in my setup, but I have one thing missing. When I used quote:: to mark my quotes, I was then able to use the following dataviewjs code to randomly select a quote that I would include at the bottom of each note:
Now that my quotes are custom tasks using - [q] , I haven’t been able to figure out how to do the same thing (a random quote including a link to the page it came from). Any suggestions on how I could replicate that?
I tried applying your suggestion to my situation (collating records of lessons I’ve learned through the day in my journal) but fell over at the first step. When I tried to apply your sample book entry, mine show as completed tasks (see photos). Is there something I need to do to fix that. Thanks Gen
PS I am using it on Android Mobile version, of that makes any difference.
Goto Settings > Appearance and scroll down to “CSS snippets” section, and hit the folder icon on the far right. This opens up a file explorer window, in the folder vault/.obsidian/snippets, which is were you want to save your css snippet
In this new window create a file, like myCss.css, where you copy the CSS into. Make sure this actually is a text file, and that the name ends in .css
Back in Obsidian, you should now see your myCss in the list of CSS snippets. If not, hit the refresh button
Final step is to click the enable button to the right of your file, and now your new CSS should be in effect
If you later on make changes in the CSS snippet file, the effect should be immediate. If not, try disabling and re-enabling the snippet, or in some strange cases, you would need to reload Obsidian. In 99% of the cases, the changes are immediate, though.