MCPcopy Create free account
hub / github.com/clientdb/clientdb / reapplyEntityChange

Function reapplyEntityChange

core/transaction.ts:144–165  ·  view source on GitHub ↗
(change: Change)

Source from the content-addressed store, hash-verified

142}
143
144function reapplyEntityChange(change: Change) {
145 const { entity } = change;
146 switch (change.type) {
147 case "created": {
148 // Nothing to apply
149 if (entity.store.findById(entity.getId())) return;
150
151 entity.store.add(change.entity);
152 return;
153 }
154 case "removed": {
155 // Nothing to apply
156 if (!entity.store.findById(entity.getId())) return;
157
158 entity.store.remove(change.entity.getId());
159 return;
160 }
161 case "updated": {
162 entity.store.update(entity.getId(), pickAfterFromChanges(change.changes));
163 }
164 }
165}
166
167function undoEntityChange(change: Change) {
168 switch (change.type) {

Callers 1

rebaseEntityChangesFunction · 0.85

Calls 5

pickAfterFromChangesFunction · 0.90
findByIdMethod · 0.80
addMethod · 0.80
removeMethod · 0.65
updateMethod · 0.65

Tested by

no test coverage detected