Bookmark
A saved URL with metadata, tags, and full-text content.
Attributes
| Attribute | Type | Description |
|---|---|---|
| url | str | The bookmarked URL. |
| title | str | Human-readable title. |
| description | str | Optional longer description. |
| tags | List[str] = [] | List of tag IDs associated with this bookmark. |
| status | [BookmarkStatus](bookmarkstatus.md?sid=app_models_bookmark_bookmarkstatus) = BookmarkStatus.ACTIVE | Current visibility status. |
| id | str = uuid.uuid4().hex[:12] | Unique identifier. |
| created_at | datetime = datetime.utcnow | Timestamp of creation. |
| updated_at | datetime = datetime.utcnow | Timestamp of last modification. |
| metadata | Dict[str, Any] = {} | Arbitrary key/value pairs for extensibility. |
Constructor
Signature
def Bookmark(
url: str,
title: str,
description: str = "",
tags: List[str] = [],
status: [BookmarkStatus](bookmarkstatus.md?sid=app_models_bookmark_bookmarkstatus) = BookmarkStatus.ACTIVE,
id: str = uuid.uuid4().hex[:12],
created_at: datetime = datetime.utcnow,
updated_at: datetime = datetime.utcnow,
metadata: Dict[str, Any] = {}
) - > None
Parameters
| Name | Type | Description |
|---|---|---|
| url | str | The bookmarked URL. |
| title | str | Human-readable title for the bookmark. |
| description | str = "" | Optional longer description of the bookmark content. |
| tags | List[str] = [] | List of tag IDs associated with this bookmark. |
| status | [BookmarkStatus](bookmarkstatus.md?sid=app_models_bookmark_bookmarkstatus) = BookmarkStatus.ACTIVE | The initial visibility status of the bookmark. |
| id | str = uuid.uuid4().hex[:12] | Unique identifier for the bookmark. |
| created_at | datetime = datetime.utcnow | Timestamp of creation. |
| updated_at | datetime = datetime.utcnow | Timestamp of last modification. |
| metadata | Dict[str, Any] = {} | Arbitrary key/value pairs for extensibility. |
Methods
archive()
@classmethod
def archive() - > None
Move the bookmark to the archive.
Returns
| Type | Description |
|---|---|
None | Nothing |
trash()
@classmethod
def trash() - > None
Soft-delete the bookmark by moving it to the trash.
Returns
| Type | Description |
|---|---|
None | Nothing |
restore()
@classmethod
def restore() - > None
Restore a trashed or archived bookmark to active status.
Returns
| Type | Description |
|---|---|
None | Nothing |
add_tag()
@classmethod
def add_tag(
tag_id: str
) - > bool
Attach a tag. Returns False if already present.
Parameters
| Name | Type | Description |
|---|---|---|
| tag_id | str | The unique identifier of the tag to associate with this bookmark |
Returns
| Type | Description |
|---|---|
bool | True if the tag was successfully added, False if the bookmark already contained the tag |
remove_tag()
@classmethod
def remove_tag(
tag_id: str
) - > bool
Detach a tag. Returns False if not found.
Parameters
| Name | Type | Description |
|---|---|---|
| tag_id | str | The unique identifier of the tag to remove from this bookmark |
Returns
| Type | Description |
|---|---|
bool | True if the tag was successfully removed, False if the tag was not found in the bookmark's tag list |
to_dict()
@classmethod
def to_dict() - > Dict[str, Any]
Serialise to a plain dictionary for JSON responses.
Returns
| Type | Description |
|---|---|
Dict[str, Any] | A dictionary representation of the bookmark including its ID, URL, title, status, and timestamps |
from_dict()
@classmethod
def from_dict(
data: Dict[str, Any]
) - > [Bookmark](bookmark.md?sid=app_models_bookmark_bookmark)
Construct a Bookmark from a dictionary (e.g. JSON body).
Parameters
| Name | Type | Description |
|---|---|---|
| data | Dict[str, Any] | Dictionary with bookmark fields. |
Returns
| Type | Description |
|---|---|
[Bookmark](bookmark.md?sid=app_models_bookmark_bookmark) | A new Bookmark instance. |