跳到主要内容

useGet()

function useGet<T>(EntityType, options): RxDBResource<InstanceType<T> | undefined>;

Defined in: hooks.ts:154

通过 ID 获取单个实体

Type Parameters

Type Parameter
T extends EntityType

Parameters

ParameterTypeDescription
EntityTypeT实体类
optionsUseOptions<EntityStaticType<T, "getOptions">>实体的 ID 或选项对象

Returns

RxDBResource<InstanceType<T> | undefined>

包含实体、加载状态和错误的资源对象

Example

const { value: user, isLoading } = useGet(User, 'user-1');