MetadataCache
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
[]>
Inherited from
app
app:
App
Reference to App
didFinish
didFinish:
Debouncer
<[],void
>
resolvedLinks
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
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
Reference to Vault
Methods
_getLinkpathDest()
_getLinkpathDest(
origin
,path
):TFile
[]
Parameters
• origin: string
• path: string
Returns
TFile
[]
fileToLinktext()
fileToLinktext(
file
,sourcePath
,omitMdExtension
?):string
Generates a linktext for a file.
If file name is unique, use the filename. If not unique, use full path.
Parameters
• file: TFile
• sourcePath: string
• omitMdExtension?: boolean
Returns
string
getAllPropertyInfos()
getAllPropertyInfos():
Record
<string
,PropertyInfo
>
Get all property infos of the vault
Returns
Record
<string
, PropertyInfo
>
getBacklinksForFile()
getBacklinksForFile(
file
):CustomArrayDict
<Reference
>
Get all backlink information for a file
Parameters
• file: TFile
Returns
getCache()
getCache(
path
):null
|CachedMetadata
Parameters
• path: string
Returns
null
| CachedMetadata
getCachedFiles()
getCachedFiles():
string
[]
Get paths of all files cached in the vault
Returns
string
[]
getFileCache()
getFileCache(
file
):null
|CachedMetadata
Parameters
• file: TFile
Returns
null
| CachedMetadata
getFileInfo()
getFileInfo(
path
):undefined
|FileCacheEntry
Get an entry from the file cache
Parameters
• path: string
Returns
undefined
| FileCacheEntry
getFirstLinkpathDest()
getFirstLinkpathDest(
linkpath
,sourcePath
):null
|TFile
Get the best match for a linkpath.
Parameters
• linkpath: string
• sourcePath: string
Returns
null
| TFile
getFrontmatterPropertyValuesForKey()
getFrontmatterPropertyValuesForKey(
key
):string
[]
Get property values for frontmatter property key
Parameters
• key: string
Returns
string
[]
getLinkpathDest()
getLinkpathDest(
origin
,path
):TFile
[]
Get destination of link path
Parameters
• origin: string
• path: string
Returns
TFile
[]
getLinks()
Get all links within the vault per file
Returns
getLinkSuggestions()
getLinkSuggestions():
LinkSuggestion
[]
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
>
Get all tags within the vault and their usage count
Returns
Record
<string
, number
>
iterateReferences()
iterateReferences(
callback
):void
Iterate over all link references in the vault with callback
Parameters
• callback
Returns
void
off()
off(
name
,callback
):void
Parameters
• name: string
• callback
Returns
void
Inherited from
offref()
offref(
ref
):void
Parameters
• ref: EventRef
Returns
void
Inherited from
on()
on(name, callback, ctx)
on(
name
,callback
,ctx
?):EventRef
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
• ctx?: any
Returns
Inherited from
on(name, callback, ctx)
on(
name
,callback
,ctx
?):EventRef
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
• ctx?: any
Returns
Inherited from
Events.on
on(name, callback, ctx)
on(
name
,callback
,ctx
?):EventRef
Called when a file has been resolved for resolvedLinks
and unresolvedLinks
.
This happens sometimes after a file has been indexed.
Parameters
• name: "resolve"
• callback
• ctx?: any
Returns
Inherited from
Events.on
on(name, callback, ctx)
on(
name
,callback
,ctx
?):EventRef
Called when all files has been resolved. This will be fired each time files get modified after the initial load.
Parameters
• name: "resolved"
• callback
• ctx?: any
Returns
Inherited from
Events.on
on(name, callback)
on(
name
,callback
):EventRef
Called whenever the metadatacache has finished updating
Parameters
• name: "finished"
• callback
Returns
Inherited from
Events.on
on(name, callback)
on(
name
,callback
):EventRef
Called whenever the metadatacache is fully loaded in
Parameters
• name: "initialized"
• callback