Skip to content

QueryAPI

Constructors

new QueryAPI()

new QueryAPI(apiInstance): QueryAPI

Parameters

Parameter Type

apiInstance

API

Returns

QueryAPI

Defined in

jsEngine/api/QueryAPI.ts:8

Properties

apiInstance

readonly apiInstance: API

Defined in

jsEngine/api/QueryAPI.ts:6

Methods

files()

files<T>(query): T[]

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);

Defined in

jsEngine/api/QueryAPI.ts:27


filesWithMetadata()

filesWithMetadata<T>(query): T[]

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) => 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);

Defined in

jsEngine/api/QueryAPI.ts:43