I am trying to add multiple entities to the store using ngrx/data -> saveEntities. So far I got this:
@Injectable()
export class MaintenanceEntityService extends EntityCollectionServiceBase<Maintenance> {
constructor(
private serviceElementsFactory: EntityCollectionServiceElementsFactory,
private entityCacheDispatcher: EntityCacheDispatcher) {
super('Maintenance', serviceElementsFactory);
}
addBatch(maintenances: Maintenance[]) {
const changes: ChangeSetItem[] = [
cif.add('Maintenance', maintenances)
];
const changeSet: ChangeSet = { changes, tag: 'Creating alert batch'};
return this.entityCacheDispatcher.saveEntities(changeSet, `${environment.API}maintenances`).pipe(
map(response => response)
);
}
}
My endpoint receives and return an object like this:
interface ChangeSet<T = any> {
changes: ChangeSetItem[]
extras?: T
tag?: string
}
In the backend I insert all entities into the database and then before returning the same object I update ids, but once again in the Angular app, the store is not getting updated. Am I missing something?