Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Different between addOne and upsertOne in ngrx/entity angular 7

As I know about docs of ngrx/entity adapter

addOne: Add one entity to the collection upsertOne: Add or Update one entity in the collection updateOne: Update one entity in the collection

Why do we need upsertOne here while we have addOne and updateOne? So can I use only upsertOne for both case: add new item or update new item? The docs makes me confused a bit

like image 210
dlam Avatar asked Sep 01 '25 23:09

dlam


1 Answers

updateOne: add the entity to the collection, does nothing if the entity is already in the store state upsertOne: add the entity to the collection, updates the existing entity in the store if it's already present

like image 135
timdeschryver Avatar answered Sep 03 '25 15:09

timdeschryver