Tankōbon / main/db/reading-list-repository / ReadingListRepository
Class: ReadingListRepository
Defined in: main/db/reading-list-repository.ts:37
Persists the reading lists: named, ordered piles of library entries. Changes that can be refused (full list, empty name, unknown list) resolve to a ReadingListResult error.
Constructors
Constructor
new ReadingListRepository(
db,userId?):ReadingListRepository
Defined in: main/db/reading-list-repository.ts:39
userId says whose lists these are (the active user, in the app): each user has their own.
Parameters
db
DatabaseSync
userId?
() => string
Returns
ReadingListRepository
Methods
addEntries()
addEntries(
id,libraryIds):ReadingListAddResult
Defined in: main/db/reading-list-repository.ts:180
Puts several library entries at the end of a list, in the order given, in one transaction. Books already in the list stay where they are; once the list holds MAX_READING_LIST_SIZE books the remaining ones are left out (counted in overLimit), and ids no longer in the library are skipped (missing). Duplicates in libraryIds count once.
Parameters
id
string
libraryIds
string[]
Returns
addEntry()
addEntry(
id,libraryId):ReadingListResult
Defined in: main/db/reading-list-repository.ts:147
Puts a library entry at the end of a list. A book already in the list stays where it is; a list already holding MAX_READING_LIST_SIZE books refuses new ones.
Parameters
id
string
libraryId
string
Returns
clear()
clear():
number
Defined in: main/db/reading-list-repository.ts:137
Deletes every list of the user; the books they held stay in the library. Returns how many were deleted.
Returns
number
create()
create(
name):ReadingListResult
Defined in: main/db/reading-list-repository.ts:92
Creates an empty list, after the existing ones. The name is trimmed and must not be empty.
Parameters
name
string
Returns
get()
get(
id):ReadingList|null
Defined in: main/db/reading-list-repository.ts:72
One list by id, or null if it doesn't exist (anymore).
Parameters
id
string
Returns
ReadingList | null
isForeign()
isForeign(
id):boolean
Defined in: main/db/reading-list-repository.ts:65
Whether a list with this id exists but belongs to another user (an imported list must then get a new id).
Parameters
id
string
Returns
boolean
list()
list():
ReadingList[]
Defined in: main/db/reading-list-repository.ts:45
Every list of the user, in the order they gave them (new lists last).
Returns
remove()
remove(
id):void
Defined in: main/db/reading-list-repository.ts:128
Deletes a list; the books it held stay in the library.
Parameters
id
string
Returns
void
removeEntry()
removeEntry(
id,libraryId):ReadingListResult
Defined in: main/db/reading-list-repository.ts:205
Takes a library entry out of a list; the book stays in the library.
Parameters
id
string
libraryId
string
Returns
rename()
rename(
id,name):ReadingListResult
Defined in: main/db/reading-list-repository.ts:103
Renames a list. The name is trimmed and must not be empty.
Parameters
id
string
name
string
Returns
reorder()
reorder(
id,entryIds):ReadingListResult
Defined in: main/db/reading-list-repository.ts:221
Stores a new order for a list. entryIds must hold exactly the list's current entries: a stale order (the list changed in the meantime) is refused rather than dropping or adding books. Which books may move (not the finished ones) is the renderer's rule, see moveUnfinished().
Parameters
id
string
entryIds
string[]
Returns
reorderLists()
reorderLists(
listIds):ReadingListOrderResult
Defined in: main/db/reading-list-repository.ts:117
Stores a new order for the lists themselves (the order of list). listIds must hold exactly the current lists: a stale order (a list was created or deleted in the meantime) is refused, like reorder's.
Parameters
listIds
string[]
Returns
upsert()
upsert(
list):"created"|"updated"
Defined in: main/db/reading-list-repository.ts:241
Writes a whole list, matching an existing one by id (list ids are random UUIDs, so unlike library ids they identify the same list across machines) — used by the JSON import. The snapshot wins: name and entries are replaced. Entries beyond MAX_READING_LIST_SIZE are dropped. An existing list keeps its place, a new one goes last; the import then applies the snapshot's order with reorderLists.
Parameters
list
Returns
"created" | "updated"