Skip to content

QueryAPI

Defined in: jsEngine/api/QueryAPI.ts:7

Constructors

new QueryAPI()

new QueryAPI(apiInstance): QueryAPI

Defined in: jsEngine/api/QueryAPI.ts:10

Parameters

Parameter Type

apiInstance

API

Returns

QueryAPI

Properties

apiInstance

readonly apiInstance: API

Defined in: jsEngine/api/QueryAPI.ts:8

Methods

files()

files<T>(query): T[]

Defined in: jsEngine/api/QueryAPI.ts:29

This function will run the query callback on every markdown file in the vault and then return a list of the results, with undefined filtered out.

Type Parameters

Type Parameter

T

Parameters

Parameter Type

query

(file) => undefined | T

Returns

T[]

Examples

// Find all markdown `TFiles` that start with the word "Foo"
const files = engine.query.files(file => file.name.startsWith("Foo") ? file : undefined);
// Find all the names of all markdown files that are in the "Foo" folder
const fileNames = engine.query.files(file => file.path.startsWith("Foo/") ? file.name : undefined);

filesWithMetadata()

filesWithMetadata<T>(query): T[]

Defined in: jsEngine/api/QueryAPI.ts:47

This function functions similarly tp QueryAPI.files, but also provides the cache and tags of each file to the query callback.

Type Parameters

Type Parameter

T

Parameters

Parameter Type

query

(file, cache, tags, frontmatterTags) => undefined | T

Returns

T[]

Example

// Find the paths of all markdown files that have the tag "Foo"
const paths = engine.query.filesWithMetadata((file, cache, tags) => tags.includes("Foo") ? file.path : undefined);

incomingLinks(file): object[]

Defined in: jsEngine/api/QueryAPI.ts:92

Parameters

Parameter Type

file

TFile

Returns

object[]


outgoingLinks(file): object[]

Defined in: jsEngine/api/QueryAPI.ts:69

Parameters

Parameter Type

file

TFile

Returns

object[]