After some database operations you might want to cause the client to automatically refetch certain queries. This is possible using $app.invalidateClientQuery - Helpers
Local files
You can interact with the scanned file entries (also called local files).
Get all
const localFiles = $database.localFiles.getAll()
Edit
// Get all 'One Piece' files
const onePieceLocalFiles = $database
.localFiles.findBy((lf) => {
return lf.mediaId === 21
})
// Lock all 'One piece' files
for (const lf of onePieceLocalFiles) {
lf.locked = true
}
$database.localFiles.save(onePieceLocalFiles)
Note that save only works for existing entries.
Insert
// Inserts a new collection of local files
// This is equivalent to doing a scan
const localFiles = $database.localFiles.insert([
//...
])
AniList
Get Token
anilist-token permission is required
$database.anilist.getToken()
Get Username
$database.anilist.getUsername()
Auto Downloader Rules
// Get all rules
$database.autoDownloaderRules.getAll()
// Get rules by media ID
const rules = $database.autoDownloaderRules.getByMediaId(21)
for (const rule of rules) {
rule.enabled = false
// Update a rule
$database.autoDownloaderRules.update(rule.dbId, rule)
}
// Remove a rule
$database.autoDownloaderRules.remove(ruleDbId)
// Insert a rule
$database.autoDownloaderRules.insert({
//...
})
Auto Downloader Items
// Get all items
$database.autoDownloaderItems.getAll()
// Get items by media ID
const items = $database.autoDownloaderItems.getByMediaId(21)
for (const item of items) {
item.enabled = false
// Update an item
$database.autoDownloaderItems.update(item.dbId, item)
}
// Remove an item
$database.autoDownloaderItems.remove(itemDbId)
// Insert an item
$database.autoDownloaderItems.insert({
//...
})