Skip to main content

Class: CollectionRepository

Defined in: Data/Repositories/CollectionRepository.ts:12

Repository for managing Collections and Pinned Items in the user database

Implements

Constructors

Constructor

new CollectionRepository(sql): CollectionRepository

Defined in: Data/Repositories/CollectionRepository.ts:13

Parameters

sql

ISql

Returns

CollectionRepository

Methods

addPinnedItem()

addPinnedItem(item): number

Defined in: Data/Repositories/CollectionRepository.ts:139

Add a pinned item to a collection

Parameters

item

PinnedItem

Returns

number

The ID of the newly created pinned item

Implementation of

ICollectionRepository.addPinnedItem


create()

create(collection): number

Defined in: Data/Repositories/CollectionRepository.ts:17

Create a new collection

Parameters

collection

Collection

Returns

number

The ID of the newly created collection

Implementation of

ICollectionRepository.create


delete()

delete(collectionId): void

Defined in: Data/Repositories/CollectionRepository.ts:70

Delete a collection and all its pinned items (CASCADE delete from database)

Parameters

collectionId

number

Returns

void

Implementation of

ICollectionRepository.delete


deletePinnedItem()

deletePinnedItem(pinId): void

Defined in: Data/Repositories/CollectionRepository.ts:202

Delete a pinned item

Parameters

pinId

number

Returns

void

Implementation of

ICollectionRepository.deletePinnedItem


findCollectionsByName()

findCollectionsByName(searchTerm): Collection[]

Defined in: Data/Repositories/CollectionRepository.ts:233

Find collections by name (case-insensitive search)

Parameters

searchTerm

string

Returns

Collection[]

Implementation of

ICollectionRepository.findCollectionsByName


getAll()

getAll(): Collection[]

Defined in: Data/Repositories/CollectionRepository.ts:86

Get all collections (flat list)

Returns

Collection[]

Implementation of

ICollectionRepository.getAll


getById()

getById(collectionId): Collection | undefined

Defined in: Data/Repositories/CollectionRepository.ts:75

Get a collection by ID

Parameters

collectionId

number

Returns

Collection | undefined

Implementation of

ICollectionRepository.getById


getChildren()

getChildren(parentId): Collection[]

Defined in: Data/Repositories/CollectionRepository.ts:98

Get child collections of a parent

Parameters

parentId

number

Returns

Collection[]

Implementation of

ICollectionRepository.getChildren


getCollectionItemCount()

getCollectionItemCount(collectionId): number

Defined in: Data/Repositories/CollectionRepository.ts:264

Get the total count of pinned items in a collection

Parameters

collectionId

number

Returns

number

Implementation of

ICollectionRepository.getCollectionItemCount


getCollectionsContainingVerse()

getCollectionsContainingVerse(verseId): Collection[]

Defined in: Data/Repositories/CollectionRepository.ts:241

Get all collections that contain a specific verse

Parameters

verseId

number

Returns

Collection[]

Collections that have a pinned item referencing this verse

Implementation of

ICollectionRepository.getCollectionsContainingVerse


getCollectionTree()

getCollectionTree(): Collection[]

Defined in: Data/Repositories/CollectionRepository.ts:106

Get a hierarchical tree of all collections (Collections with child collections populated)

Returns

Collection[]

Implementation of

ICollectionRepository.getCollectionTree


getPinnedItem()

getPinnedItem(pinId): PinnedItem | undefined

Defined in: Data/Repositories/CollectionRepository.ts:206

Get a single pinned item by ID

Parameters

pinId

number

Returns

PinnedItem | undefined

Implementation of

ICollectionRepository.getPinnedItem


getPinnedItemsByVerse()

getPinnedItemsByVerse(verseId): PinnedItem[]

Defined in: Data/Repositories/CollectionRepository.ts:220

Get all pinned items that reference a specific verse (Useful for checking if a verse is bookmarked)

Parameters

verseId

number

Returns

PinnedItem[]

Implementation of

ICollectionRepository.getPinnedItemsByVerse


getPinnedItemsForCollection()

getPinnedItemsForCollection(collectionId): PinnedItem[]

Defined in: Data/Repositories/CollectionRepository.ts:212

Get all pinned items for a specific collection

Parameters

collectionId

number

Returns

PinnedItem[]

Pinned items sorted by sort_order

Implementation of

ICollectionRepository.getPinnedItemsForCollection


getTopLevel()

getTopLevel(): Collection[]

Defined in: Data/Repositories/CollectionRepository.ts:91

Get only top-level collections (parent_collection_id IS NULL)

Returns

Collection[]

Implementation of

ICollectionRepository.getTopLevel


isVerseBookmarked()

isVerseBookmarked(verseId): boolean

Defined in: Data/Repositories/CollectionRepository.ts:254

Check if a verse is pinned in any collection

Parameters

verseId

number

Returns

boolean

Implementation of

ICollectionRepository.isVerseBookmarked


moveCollection()

moveCollection(collectionId, newParentId): void

Defined in: Data/Repositories/CollectionRepository.ts:274

Move a collection to a different parent

Parameters

collectionId

number

The collection to move

newParentId

number | null

The new parent (null for top-level)

Returns

void

Implementation of

ICollectionRepository.moveCollection


reorderCollections()

reorderCollections(collectionIds): void

Defined in: Data/Repositories/CollectionRepository.ts:281

Reorder collections within the same parent

Parameters

collectionIds

number[]

Array of collection IDs in desired order

Returns

void

Implementation of

ICollectionRepository.reorderCollections


reorderPinnedItems()

reorderPinnedItems(pinIds): void

Defined in: Data/Repositories/CollectionRepository.ts:292

Reorder pinned items within a collection

Parameters

pinIds

number[]

Array of pin IDs in desired order

Returns

void

Implementation of

ICollectionRepository.reorderPinnedItems


update()

update(collection): void

Defined in: Data/Repositories/CollectionRepository.ts:38

Update an existing collection

Parameters

collection

Collection

Returns

void

Implementation of

ICollectionRepository.update


updatePinnedItem()

updatePinnedItem(item): void

Defined in: Data/Repositories/CollectionRepository.ts:165

Update an existing pinned item

Parameters

item

PinnedItem

Returns

void

Implementation of

ICollectionRepository.updatePinnedItem