Skip to content

List the most recent contact with a certain person, or the most recent day you baked banana cake, or made a certain type of sports, for example.

Contributed via Discord

List most recent meta data value that contains a certain phrase

Basic

LIST met
FROM "10 Example Data/dailys"
WHERE contains(met, "Sophie")
SORT file.name DESC
LIMIT 1

Variants

As an javascript inline field

Usage

A inline query can be i.e. used as a field for the Kanban Board Plugin

$=const notes = dv.pages('"10 Example Data/dailys"').where(p => p.met).where(p => String(p.met).includes("Sophie")).sort((p) => p.file.name, 'desc').limit(1); if (notes.length) { const content = notes.flatMap(m => dv.array(m.met)).where(m => m.includes("Sophie")).last(); dv.span(notes[0].file.link + ": " + content); }

When editing this, it can be helpful to put it into a regular dataviewjs block while editing for better readability:

const notes = dv.pages('"10 Example Data/dailys"')
    .where(p => p.met)
    .where(p => String(p.met)
    .includes("Sophie"))
    .sort((p) => p.file.name, 'desc')
    .limit(1); 

if (notes.length) { 
    const content = notes
        .flatMap(m => dv.array(m.met)).where(m => m.includes("Sophie"))
        .last(); 

    dv.span(notes[0].file.link + ": " + content); 
}