How to get backlinks for a file?

There are actually a lot of things that are available in JS but not in TS.

console.log(Object.keys(this.app.metadataCache))
/* [
  "_",
  "worker",
  "inProgressTaskCount",
  "db",
  "fileCache",
  "metadataCache",
  "workQueue",
  "uniqueFileLookup",
  "initialized",
  "resolvedLinks",
  "unresolvedLinks",
  "linkResolverQueue",
  "onCleanCacheCallbacks",
  "workerResolve",
  "userIgnoreFilters",
  "userIgnoreFiltersString",
  "userIgnoreFilterCache",
  "app",
  "vault",
  "blockCache",
] */

console.log(Object.keys(this.app.metadataCache._))
// ['finished', 'resolved', 'resolve', 'changed']

// Inspecting the this.app.metadataCache prototype and storing as global var `temp4`
console.log(Object.keys(temp4))
/* [
  "constructor",
  "getLinkSuggestions",
  "getTags",
  "getLinkpathDest",
  "getFirstLinkpathDest",
  "_getLinkpathDest",
  "getLinks",
  "getFileCache",
  "getCache",
  "getFileInfo",
  "getCachedFiles",
  "iterateReferences",
  "getBacklinksForFile",
  "fileToLinktext",
  "watchVaultChanges",
  "initialize",
  "clear",
  "showIndexingNotice",
  "linkResolver",
  "resolveLinks",
  "onCleanCache",
  "checkCleanCache",
  "isCacheClean",
  "updateRelatedLinks",
  "onCreate",
  "onCreateOrModify",
  "onDelete",
  "deletePath",
  "onRename",
  "saveFileCache",
  "saveMetaCache",
  "work",
  "computeMetadataAsync",
  "onReceiveMessageFromWorker",
  "cleanupDeletedCache",
  "updateUserIgnoreFilters",
  "isSupportedFile",
  "isUserIgnored",
  "getFrontmatterFieldValuesForKey",
  "trigger",
  "on",
] */
1 Like