MCPcopy Index your code
hub / github.com/strongloop/loopback / doRectify

Function doRectify

common/models/change.js:223–265  ·  view source on GitHub ↗
(checkpoint, rev)

Source from the content-addressed store, hash-verified

221 }
222
223 function doRectify(checkpoint, rev) {
224 if (rev) {
225 if (currentRev === rev) {
226 change.debug('ASSERTION FAILED: Change currentRev==rev ' +
227 'should have been already handled');
228 return cb(null, change);
229 } else {
230 change.rev = rev;
231 change.debug('updated revision (was ' + currentRev + ')');
232 if (change.checkpoint !== checkpoint) {
233 // previous revision is updated only across checkpoints
234 change.prev = currentRev;
235 change.debug('updated prev');
236 }
237 }
238 } else {
239 change.rev = null;
240 change.debug('updated revision (was ' + currentRev + ')');
241 if (change.checkpoint !== checkpoint) {
242 // previous revision is updated only across checkpoints
243 if (currentRev) {
244 change.prev = currentRev;
245 } else if (!change.prev) {
246 change.debug('ERROR - could not determine prev');
247 change.prev = Change.UNKNOWN;
248 }
249 change.debug('updated prev');
250 }
251 }
252
253 if (change.checkpoint != checkpoint) {
254 debug('update checkpoint to', checkpoint);
255 change.checkpoint = checkpoint;
256 }
257
258 if (change.prev === Change.UNKNOWN) {
259 // this occurs when a record of a change doesn't exist
260 // and its current revision is null (not found)
261 change.remove(cb);
262 } else {
263 change.save(cb);
264 }
265 }
266 };
267
268 /**

Callers 1

prepareAndDoRectifyFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…