Skip to main content

BookmarkRepository

In-memory storage for bookmarks, tags, and collections. All mutation methods persist immediately (since this is in-memory). For a real database you'd add transaction support here.

Constructor

Signature

def BookmarkRepository() - > None

Methods


save_bookmark()

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

Insert or update a bookmark.

Parameters

NameTypeDescription
bookmark[Bookmark](../../models/bookmark/bookmark.md?sid=app_models_bookmark_bookmark)The bookmark object to save.

Returns

TypeDescription
NoneThis method does not return a value.

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 object if found, otherwise None.

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 delete.

Returns

TypeDescription
boolTrue if the bookmark was found and deleted, 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, sorted by creation date in descending order. Filters by status if provided.

Parameters

NameTypeDescription
pageint = 1The 1-based index of the page to retrieve.
per_pageint = 25The number of bookmarks to include per page.
statusOptional[str] = NoneAn optional status string (e.g., 'active', 'archived', 'trashed') to filter the bookmarks.

Returns

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

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 to filter bookmarks by.

Returns

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

save_tag()

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

Insert or update a tag.

Parameters

NameTypeDescription
tag[Tag](../../models/tag/tag.md?sid=app_models_tag_tag)The tag object to save.

Returns

TypeDescription
NoneThis method does not return a value.

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 object if found, otherwise None.

delete_tag()

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

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

Parameters

NameTypeDescription
tag_idstrThe unique identifier of the tag to delete.

Returns

TypeDescription
boolTrue if the tag was found and deleted, 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 of all tag objects.

save_collection()

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

Insert or update a collection.

Parameters

NameTypeDescription
collection[Collection](../../models/collection/collection.md?sid=app_models_collection_collection)The collection object to save.

Returns

TypeDescription
NoneThis method does not return a value.

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 object if found, otherwise None.

delete_collection()

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

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

Parameters

NameTypeDescription
collection_idstrThe unique identifier of the collection to delete.

Returns

TypeDescription
boolTrue if the collection was found and deleted, 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 of all collection objects.