taolib.testing.oauth.repository.connection_repo#

OAuth 连接 Repository 模块。

提供 OAuth 连接的数据访问操作。

Classes#

OAuthConnectionRepository

OAuth 连接数据访问层。

Module Contents#

class taolib.testing.oauth.repository.connection_repo.OAuthConnectionRepository(collection)#

Bases: taolib.testing._base.repository.AsyncRepository[taolib.testing.oauth.models.connection.OAuthConnectionDocument]

OAuth 连接数据访问层。

async find_by_user_and_provider(user_id: str, provider: taolib.testing.oauth.models.enums.OAuthProvider | str) taolib.testing.oauth.models.connection.OAuthConnectionDocument | None#

按用户 ID 和提供商查找连接。

参数:
  • user_id -- 本地用户 ID

  • provider -- OAuth 提供商

返回:

连接文档,不存在则返回 None

async find_by_provider_user_id(provider: taolib.testing.oauth.models.enums.OAuthProvider | str, provider_user_id: str) taolib.testing.oauth.models.connection.OAuthConnectionDocument | None#

按提供商和提供商侧用户 ID 查找连接。

参数:
  • provider -- OAuth 提供商

  • provider_user_id -- 提供商侧用户 ID

返回:

连接文档,不存在则返回 None

async find_all_for_user(user_id: str) list[taolib.testing.oauth.models.connection.OAuthConnectionDocument]#

获取指定用户的所有 OAuth 连接。

参数:

user_id -- 本地用户 ID

返回:

连接文档列表

async count_active_for_user(user_id: str) int#

统计用户的活跃连接数。

参数:

user_id -- 本地用户 ID

返回:

活跃连接数量

async create_indexes() None#

创建 MongoDB 索引。