Skip to main content

Tag

A label that can be attached to one or more bookmarks.

Attributes

AttributeTypeDescription
idstringUnique identifier.
namestringDisplay name (must be unique per user).
color[TagColor](tagcolor.md?sid=app_models_tag_tagcolor) = TagColor.GRAYVisual colour for UI rendering.
descriptionstringOptional description of what this tag represents.
usage_countinteger = 0Number of bookmarks currently using this tag.

Methods


rename()

@classmethod
def rename(
new_name: str
)

Rename the tag.

Parameters

NameTypeDescription
new_namestrThe new display name for the tag.

increment_usage()

@classmethod
def increment_usage() - > int

Record that a bookmark now uses this tag. Returns new count.

Returns

TypeDescription
intThe updated total number of bookmarks associated with this tag.

decrement_usage()

@classmethod
def decrement_usage() - > int

Record that a bookmark removed this tag. Returns new count.

Returns

TypeDescription
intThe updated total number of bookmarks associated with this tag, ensuring it does not drop below zero.

to_dict()

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

Serialise to a JSON-safe dictionary.

Returns

TypeDescription
Dict[str, Any]A dictionary representation of the tag containing its ID, name, color, description, and usage count.

from_dict()

@classmethod
def from_dict(
data: Dict[str, Any]
) - > [Tag](tag.md?sid=app_models_tag_tag)

Construct a Tag from a dictionary.

Parameters

NameTypeDescription
dataDict[str, Any]A dictionary containing tag attributes such as name, color, and description.

Returns

TypeDescription
[Tag](tag.md?sid=app_models_tag_tag)A new Tag instance populated with the provided dictionary data.