Skip to main content

Collection

A named group of bookmarks.

Attributes​

AttributeTypeDescription
namestrDisplay name.
collection_type[CollectionType](collectiontype.md?sid=app_models_collection_collectiontype) = CollectionType.MANUALWhether the collection is manual or smart.
bookmark_idsList[str] = []Ordered list of bookmark IDs in the collection.
filter_rulestrFor smart collections, a query string that selects bookmarks.
is_pinnedbool = FalseWhether the collection appears at the top of the sidebar.
idstr = uuid.uuid4().hex[:10]Unique identifier.
created_atdatetime = datetime.utcnowCreation timestamp.

Methods​


size()​

@classmethod
def size() - > int

Number of bookmarks in the collection.

Returns​

TypeDescription
intThe total count of bookmark IDs currently stored in the collection

is_smart()​

@classmethod
def is_smart() - > bool

Whether this collection auto-populates based on a filter rule.

Returns​

TypeDescription
boolTrue if the collection type is SMART, False otherwise

add_bookmark()​

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

Add a bookmark to a manual collection.

Parameters​

NameTypeDescription
bookmark_idstrID of the bookmark to add.

Returns​

TypeDescription
boolTrue if added, False if already present or collection is smart.

remove_bookmark()​

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

Remove a bookmark from the collection.

Parameters​

NameTypeDescription
bookmark_idstrThe unique identifier of the bookmark to be removed

Returns​

TypeDescription
boolTrue if the bookmark was successfully removed, False if the ID was not found

reorder()​

@classmethod
def reorder(
bookmark_ids: List[str]
) - > null

Replace the bookmark ordering.

Parameters​

NameTypeDescription
bookmark_idsList[str]New ordered list. Must contain the same IDs.

Returns​

TypeDescription
null

pin()​

@classmethod
def pin() - > null

Pin the collection to the top of the sidebar.

Returns​

TypeDescription
null

unpin()​

@classmethod
def unpin() - > null

Unpin the collection.

Returns​

TypeDescription
null

to_dict()​

@classmethod
def to_dict() - > Dict[str, Any]

Serialise to JSON-safe dictionary.

Returns​

TypeDescription
Dict[str, Any]A dictionary containing the collection's metadata, IDs, and state

from_dict()​

@classmethod
def from_dict(
data: Dict[str, Any]
) - > [Collection](collection.md?sid=app_models_collection_collection)

Construct from a dictionary.

Parameters​

NameTypeDescription
dataDict[str, Any]A dictionary containing collection attributes like name and type

Returns​

TypeDescription
[Collection](collection.md?sid=app_models_collection_collection)A new instance of the Collection class populated with the provided data