Skip to main content

BookmarkRepository

In-memory storage for bookmarks, tags, and collections.

Attributes

AttributeTypeDescription
_bookmarksDict[str, [Bookmark](../../models/bookmark/bookmark.md?sid=app_models_bookmark_bookmark)] = {}A dictionary mapping unique bookmark IDs to Bookmark objects for in-memory storage and retrieval.
_tagsDict[str, [Tag](../../models/tag/tag.md?sid=app_models_tag_tag)] = {}A dictionary mapping unique tag IDs to Tag objects used to manage and filter bookmarks.
_collectionsDict[str, [Collection](../../models/collection/collection.md?sid=app_models_collection_collection)] = {}A dictionary mapping unique collection IDs to Collection objects for organizing bookmarks into groups.

Constructor

Signature

def BookmarkRepository() - > None

Signature

def BookmarkRepository()

Methods


save_bookmark()

@classmethod
def save_bookmark(
bookmark: [Bookmark](../../models/bookmark/bookmark.md?sid=app_models_bookmark_bookmark)
)

Insert or update a bookmark.

Parameters

NameTypeDescription
bookmark[Bookmark](../../models/bookmark/bookmark.md?sid=app_models_bookmark_bookmark)The bookmark entity to be persisted or updated in the repository

get_bookmark()

@classmethod
def get_bookmark(
bookmark_id: str
) - > Optional[[Bookmark](../../models/bookmark/bookmark.md?sid=app_models_bookmark_bookmark)]

Retrieve a bookmark by ID, or None.

Parameters

NameTypeDescription
bookmark_idstrThe unique identifier of the bookmark to retrieve

Returns

TypeDescription
Optional[[Bookmark](../../models/bookmark/bookmark.md?sid=app_models_bookmark_bookmark)]The bookmark matching the provided ID, or None if no such bookmark exists

delete_bookmark()

@classmethod
def delete_bookmark(
bookmark_id: str
) - > bool

Hard-delete a bookmark. Returns True if it existed.

Parameters

NameTypeDescription
bookmark_idstrThe unique identifier of the bookmark to be permanently deleted

Returns

TypeDescription
boolTrue if the bookmark was found and removed, False otherwise

list_bookmarks()

@classmethod
def list_bookmarks(
page: int = 1,
per_page: int = 25,
status: Optional[str] = None
) - > Tuple[List[[Bookmark](../../models/bookmark/bookmark.md?sid=app_models_bookmark_bookmark)], int]

Return a paginated slice of bookmarks.

Parameters

NameTypeDescription
pageint = 1The 1-based page index for pagination
per_pageint = 25The maximum number of items to return per page
statusOptional[str] = NoneOptional status filter string such as active, archived, or trashed

Returns

TypeDescription
Tuple[List[[Bookmark](../../models/bookmark/bookmark.md?sid=app_models_bookmark_bookmark)], int]A tuple containing the list of bookmarks for the current page and the total count of matching bookmarks

get_bookmarks_with_tag()

@classmethod
def get_bookmarks_with_tag(
tag_id: str
) - > List[[Bookmark](../../models/bookmark/bookmark.md?sid=app_models_bookmark_bookmark)]

Return all bookmarks that have a specific tag attached.

Parameters

NameTypeDescription
tag_idstrThe unique identifier of the tag used to filter bookmarks

Returns

TypeDescription
List[[Bookmark](../../models/bookmark/bookmark.md?sid=app_models_bookmark_bookmark)]A list of bookmarks associated with the specified tag ID

save_tag()

@classmethod
def save_tag(
tag: [Tag](../../models/tag/tag.md?sid=app_models_tag_tag)
)

Insert or update a tag.

Parameters

NameTypeDescription
tag[Tag](../../models/tag/tag.md?sid=app_models_tag_tag)The tag entity to be persisted or updated in the repository

get_tag()

@classmethod
def get_tag(
tag_id: str
) - > Optional[[Tag](../../models/tag/tag.md?sid=app_models_tag_tag)]

Retrieve a tag by ID, or None.

Parameters

NameTypeDescription
tag_idstrThe unique identifier of the tag to retrieve

Returns

TypeDescription
Optional[[Tag](../../models/tag/tag.md?sid=app_models_tag_tag)]The tag matching the provided ID, or None if no such tag exists

delete_tag()

@classmethod
def delete_tag(
tag_id: str
) - > bool

Hard-delete a tag.

Parameters

NameTypeDescription
tag_idstrThe unique identifier of the tag to be permanently deleted

Returns

TypeDescription
boolTrue if the tag was found and removed, False otherwise

list_tags()

@classmethod
def list_tags() - > List[[Tag](../../models/tag/tag.md?sid=app_models_tag_tag)]

Return all tags.

Returns

TypeDescription
List[[Tag](../../models/tag/tag.md?sid=app_models_tag_tag)]A list containing all tag entities stored in the repository

save_collection()

@classmethod
def save_collection(
collection: [Collection](../../models/collection/collection.md?sid=app_models_collection_collection)
)

Insert or update a collection.

Parameters

NameTypeDescription
collection[Collection](../../models/collection/collection.md?sid=app_models_collection_collection)The collection entity to be persisted or updated in the repository

get_collection()

@classmethod
def get_collection(
collection_id: str
) - > Optional[[Collection](../../models/collection/collection.md?sid=app_models_collection_collection)]

Retrieve a collection by ID, or None.

Parameters

NameTypeDescription
collection_idstrThe unique identifier of the collection to retrieve

Returns

TypeDescription
Optional[[Collection](../../models/collection/collection.md?sid=app_models_collection_collection)]The collection matching the provided ID, or None if no such collection exists

delete_collection()

@classmethod
def delete_collection(
collection_id: str
) - > bool

Hard-delete a collection.

Parameters

NameTypeDescription
collection_idstrThe unique identifier of the collection to be permanently deleted

Returns

TypeDescription
boolTrue if the collection was found and removed, False otherwise

list_collections()

@classmethod
def list_collections() - > List[[Collection](../../models/collection/collection.md?sid=app_models_collection_collection)]

Return all collections.

Returns

TypeDescription
List[[Collection](../../models/collection/collection.md?sid=app_models_collection_collection)]A list containing all collection entities stored in the repository