MetadataCache
Defined in: obsidian.d.ts:2736
Linktext is any internal link that is composed of a path and a subpath, such as ‘My note#Heading’ Linkpath (or path) is the path part of a linktext Subpath is the heading/block ID part of a linktext.
Extends
Constructors
new MetadataCache()
new MetadataCache():
MetadataCache
Returns
Inherited from
Properties
_
_:
Record
<string
,EventsEntry
[]>
Defined in: src/obsidian/augmentations/Events.d.ts:5
Inherited from
app
app:
App
Defined in: src/obsidian/augmentations/MetadataCache.d.ts:19
Reference to App
didFinish
didFinish:
Debouncer
<[],void
>
Defined in: src/obsidian/augmentations/MetadataCache.d.ts:24
resolvedLinks
Defined in: obsidian.d.ts:2767
Contains all resolved links. This object maps each source file’s path to an object of destination file paths with the link count.
Source and destination paths are all vault absolute paths that comes from TFile.path
and can be used with Vault.getAbstractFileByPath(path)
.
unresolvedLinks
Defined in: obsidian.d.ts:2773
Contains all unresolved links. This object maps each source file to an object of unknown destinations with count.
Source paths are all vault absolute paths, similar to resolvedLinks
.
vault
vault:
Vault
Defined in: src/obsidian/augmentations/MetadataCache.d.ts:48
Reference to Vault
Methods
_getLinkpathDest()
_getLinkpathDest(
origin
,path
):TFile
[]
Defined in: src/obsidian/augmentations/MetadataCache.d.ts:56
Parameters
origin
string
path
string
Returns
TFile
[]
fileToLinktext()
fileToLinktext(
file
,sourcePath
,omitMdExtension
?):string
Defined in: obsidian.d.ts:2760
Generates a linktext for a file.
If file name is unique, use the filename. If not unique, use full path.
Parameters
file
sourcePath
string
omitMdExtension?
boolean
Returns
string
getAllPropertyInfos()
getAllPropertyInfos():
Record
<string
,PropertyInfo
>
Defined in: src/obsidian/augmentations/MetadataCache.d.ts:68
Get all property infos of the vault
Returns
Record
<string
, PropertyInfo
>
getBacklinksForFile()
getBacklinksForFile(
file
):CustomArrayDict
<Reference
>
Defined in: src/obsidian/augmentations/MetadataCache.d.ts:72
Get all backlink information for a file
Parameters
file
Returns
getCache()
getCache(
path
):null
|CachedMetadata
Defined in: obsidian.d.ts:2751
Parameters
path
string
Returns
null
| CachedMetadata
getCachedFiles()
getCachedFiles():
string
[]
Defined in: src/obsidian/augmentations/MetadataCache.d.ts:76
Get paths of all files cached in the vault
Returns
string
[]
getFileCache()
getFileCache(
file
):null
|CachedMetadata
Defined in: obsidian.d.ts:2747
Parameters
file
Returns
null
| CachedMetadata
getFileInfo()
getFileInfo(
path
):undefined
|FileCacheEntry
Defined in: src/obsidian/augmentations/MetadataCache.d.ts:80
Get an entry from the file cache
Parameters
path
string
Returns
undefined
| FileCacheEntry
getFirstLinkpathDest()
getFirstLinkpathDest(
linkpath
,sourcePath
):null
|TFile
Defined in: obsidian.d.ts:2742
Get the best match for a linkpath.
Parameters
linkpath
string
sourcePath
string
Returns
null
| TFile
getFrontmatterPropertyValuesForKey()
getFrontmatterPropertyValuesForKey(
key
):string
[]
Defined in: src/obsidian/augmentations/MetadataCache.d.ts:84
Get property values for frontmatter property key
Parameters
key
string
Returns
string
[]
getLinkpathDest()
getLinkpathDest(
origin
,path
):TFile
[]
Defined in: src/obsidian/augmentations/MetadataCache.d.ts:88
Get destination of link path
Parameters
origin
string
path
string
Returns
TFile
[]
getLinks()
Defined in: src/obsidian/augmentations/MetadataCache.d.ts:92
Get all links within the vault per file
Returns
getLinkSuggestions()
getLinkSuggestions():
LinkSuggestion
[]
Defined in: src/obsidian/augmentations/MetadataCache.d.ts:97
Get all links (resolved or unresolved) in the vault. If the note has multiple aliases, it will be returned multiple times for each alias.
Returns
getTags()
getTags():
Record
<string
,number
>
Defined in: src/obsidian/augmentations/MetadataCache.d.ts:101
Get all tags within the vault and their usage count
Returns
Record
<string
, number
>
iterateReferences()
iterateReferences(
callback
):void
Defined in: src/obsidian/augmentations/MetadataCache.d.ts:113
Iterate over all link references in the vault with callback
Parameters
callback
(path
) => void
Returns
void
off()
off(
name
,callback
):void
Defined in: obsidian.d.ts:1441
Parameters
name
string
callback
(…data
) => unknown
Returns
void
Inherited from
offref()
offref(
ref
):void
Defined in: obsidian.d.ts:1445
Parameters
ref
Returns
void
Inherited from
on()
Call Signature
on(
name
,callback
,ctx
?):EventRef
Defined in: obsidian.d.ts:2782
Called when a file has been indexed, and its (updated) cache is now available.
Note: This is not called when a file is renamed for performance reasons. You must hook the vault rename event for those.
Parameters
name
"changed"
callback
(file
, data
, cache
) => any
ctx?
any
Returns
Inherited from
Call Signature
on(
name
,callback
,ctx
?):EventRef
Defined in: obsidian.d.ts:2788
Called when a file has been deleted. A best-effort previous version of the cached metadata is presented, but it could be null in case the file was not successfully cached previously.
Parameters
name
"deleted"
callback
(file
, prevCache
) => any
ctx?
any
Returns
Inherited from
Events.on
Call Signature
on(
name
,callback
,ctx
?):EventRef
Defined in: obsidian.d.ts:2795
Called when a file has been resolved for resolvedLinks
and unresolvedLinks
.
This happens sometimes after a file has been indexed.
Parameters
name
"resolve"
callback
(file
) => any
ctx?
any
Returns
Inherited from
Events.on
Call Signature
on(
name
,callback
,ctx
?):EventRef
Defined in: obsidian.d.ts:2800
Called when all files has been resolved. This will be fired each time files get modified after the initial load.
Parameters
name
"resolved"
callback
() => any
ctx?
any
Returns
Inherited from
Events.on
Call Signature
on(
name
,callback
):EventRef
Defined in: src/obsidian/augmentations/MetadataCache.d.ts:119
Called whenever the metadatacache has finished updating
Parameters
name
"finished"
callback
() => void
Returns
Inherited from
Events.on
Call Signature
on(
name
,callback
):EventRef
Defined in: src/obsidian/augmentations/MetadataCache.d.ts:125
Called whenever the metadatacache is fully loaded in
Parameters
name
"initialized"
callback
() => void