Skip to content

readManyFrom()

Function

readManyFrom<S, EntityType, IDType>(queryEntity: QueryEntity<S, EntityType, IDType>, ids: IDType[]): Read<EntityType[]>

Create a new Read by selecting multiple entities from a QueryEntity using an array of ids:

ts
const entities$: Read<EntityData[]> = readManyFrom(queryEntity, ['id1', 'id2']);

Source: akita-read/src/lib/read-many-from.ts:19

Type parameters

ParameterDefaultDescription
S extends EntityState<any, any>-entity state used by the queryEntity
EntityTypegetEntityType<S>-
IDTypegetIDType<S>-

Parameters

ParameterTypeDescription
queryEntityQueryEntity<S, EntityType, IDType>QueryEntity to select from
idsIDType[]array of entity ids to select

Returns

Read<EntityType[]>

Returns a new Read that emits a array containing all selected entities that exist.

readManyFrom<S, R, EntityType, IDType>( queryEntity: QueryEntity<S, EntityType, IDType>, ids: IDType[], projection: Function): Read<R[]>

Create a new Read by selecting multiple entities from a QueryEntity using an array of ids and extracting the value using a given projection:

ts
const names$: Read<string[]> = readEntityFrom(queryEntity, ['id1', 'id2'], (entity) => entity.name);

Source: akita-read/src/lib/read-many-from.ts:40

Type parameters

ParameterDefaultDescription
S extends EntityState<any, any>-entity state used by the queryEntity
R-returned type of the projection
EntityTypegetEntityType<S>-
IDTypegetIDType<S>-

Parameters

ParameterTypeDescription
queryEntityQueryEntity<S, EntityType, IDType>QueryEntity to select from
idsIDType[]array of entity ids to select
projection(entity: EntityType) => Rprojection to pick from the entity

Returns

Read<R[]>

Returns a new Read that emits the result of the projection or undefined if the entity does not exist