import { OrArray, Reducer } from '@ngneat/elf'; import { AddEntitiesOptions } from './add.mutation'; import { BaseEntityOptions, DefaultEntitiesRef, EntitiesRef, EntitiesState, getEntityType, getIdType, ItemPredicate } from './entity.state'; export type UpdateFn = Partial | ((entity: Entity) => Entity); /** * * Update entities * * @example * * store.update(updateEntities(id, { name })) * store.update(updateEntities(id, entity => ({ ...entity, name }))) * store.update(updateEntities([id, id, id], { open: true })) * */ export declare function updateEntities, U extends UpdateFn>, Ref extends EntitiesRef = DefaultEntitiesRef>(ids: OrArray>, updater: U, options?: BaseEntityOptions): Reducer; /** * * Update entities by predicate * * @example * * store.update(updateEntitiesByPredicate(entity => entity.count === 0)) * */ export declare function updateEntitiesByPredicate, U extends UpdateFn>, Ref extends EntitiesRef = DefaultEntitiesRef>(predicate: ItemPredicate>, updater: U, options?: BaseEntityOptions): Reducer; /** * * Update all entities * * @example * * store.update(updateAllEntities({ name })) * store.update(updateAllEntities(entity => ({ ...entity, name }))) * */ export declare function updateAllEntities, U extends UpdateFn>, Ref extends EntitiesRef = DefaultEntitiesRef>(updater: U, options?: BaseEntityOptions): Reducer; type CreateFn = (id: ID) => Entity; /** * * Update entities that exists, add those who don't * * @example * */ export declare function upsertEntitiesById, U extends UpdateFn, C extends CreateFn>, Ref extends EntitiesRef = DefaultEntitiesRef, EntityType = getEntityType>(ids: OrArray>, { updater, creator, ...options }: { updater: U; creator: C; mergeUpdaterWithCreator?: boolean; } & AddEntitiesOptions & BaseEntityOptions): Reducer; /** * * Merge entities that exists, add those who don't * Make sure all entities have an id * * @example * * // single entity * store.update(upsertEntities({ id: 1, completed: true })) * * // or multiple entities * store.update(upsertEntities([{ id: 1, completed: true }, { id: 2, completed: true }])) * * // or using a custom ref * store.update(upsertEntities([{ id: 1, open: true }], { ref: UIEntitiesRef })) * */ export declare function upsertEntities, Ref extends EntitiesRef = DefaultEntitiesRef>(entities: OrArray>>, options?: AddEntitiesOptions & BaseEntityOptions): Reducer; /** * Update entities ids * * @example * * // Update a single entity id * store.update(updateEntitiesIds(1, 2)); * * // Update multiple entities ids * store.update(updateEntitiesIds([1, 2], [10, 20])); * * // Update entity id using a custom ref * store.update(updateEntitiesIds(1, 2, { ref: UIEntitiesRef })); * */ export declare function updateEntitiesIds, Ref extends EntitiesRef = DefaultEntitiesRef>(oldId: OrArray>, newId: OrArray>, options?: BaseEntityOptions): Reducer; export {};