Collection
A named group of bookmarks. Collections can be manual (user adds bookmarks explicitly) or smart (bookmarks are included automatically based on a filter rule).
Attributes
| Attribute | Type | Description |
|---|---|---|
| name | str | Display name. |
| collection_type | [CollectionType](collectiontype.md?sid=app_models_collection_collectiontype) = CollectionType.MANUAL | Whether the collection is manual or smart. |
| bookmark_ids | List[str] = [] | Ordered list of bookmark IDs in the collection. |
| filter_rule | str = "" | For smart collections, a query string that selects bookmarks. |
| is_pinned | bool = False | Whether the collection appears at the top of the sidebar. |
| id | str | Unique identifier. |
| created_at | datetime | Creation timestamp. |
Methods
size()
@property
def size(self) -> int: ...
Number of bookmarks in the collection.
Returns
| Type | Description |
|---|---|
int | The number of bookmarks in the collection. |
is_smart()
@property
def is_smart(self) -> bool: ...
Whether this collection auto-populates based on a filter rule.
Returns
| Type | Description |
|---|---|
bool | True if the collection is smart, False otherwise. |
add_bookmark()
def add_bookmark(self, bookmark_id: str) -> bool: ...
Add a bookmark to a manual collection.
Parameters
| Name | Type | Description |
|---|---|---|
| bookmark_id | str | ID of the bookmark to add. |
Returns
| Type | Description |
|---|---|
bool | True if added, False if already present or collection is smart. |
remove_bookmark()
def remove_bookmark(self, bookmark_id: str) -> bool: ...
Remove a bookmark from the collection.
Parameters
| Name | Type | Description |
|---|---|---|
| bookmark_id | str | The ID of the bookmark to remove from the collection. |
Returns
| Type | Description |
|---|---|
bool | True if the bookmark was removed, False if it was not found in the collection. |
reorder()
def reorder(self, bookmark_ids: List[str]) -> None: ...
Replace the bookmark ordering.
Parameters
| Name | Type | Description |
|---|---|---|
| bookmark_ids | List[str] | New ordered list. Must contain the same IDs. |
Returns
| Type | Description |
|---|---|
None | This method does not return any value. |
pin()
def pin(self) -> None: ...
Pin the collection to the top of the sidebar.
Returns
| Type | Description |
|---|---|
None | This method does not return any value. |
unpin()
def unpin(self) -> None: ...
Unpin the collection.
Returns
| Type | Description |
|---|---|
None | This method does not return any value. |
to_dict()
def to_dict(self) -> Dict[str, Any]: ...
Serialise to JSON-safe dictionary.
Returns
| Type | Description |
|---|---|
Dict[str, Any] | A dictionary representation of the collection, suitable for JSON serialization. |
from_dict()
@classmethod
def from_dict(cls, data: Dict[str, Any]) -> "Collection": ...
Construct from a dictionary.
Parameters
| Name | Type | Description |
|---|---|---|
| data | Dict[str, Any] | A dictionary containing the data to construct the Collection. |
Returns
| Type | Description |
|---|---|
[Collection](collection.md?sid=app_models_collection_collection) | A new Collection instance initialized from the provided dictionary data. |