Nautical Poseidon Mythology
Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

object-patch

1.0.3 • Public • Published

object-patch

Deep object extend / merge with a mongo-like $inc operator.

Usage

var patch = require('object-patch');
 
var document = {
  name: 'Dan Scanlon',
  grade: 6,
  country: 'USA',
  state: 'PA',
  rewardPoints: {
    outstanding: 600,
    total: 12000,
    monthly: []
  }
};
 
var documentPatch = {
  school: 'SAHS',
  grade: 7,
  rewardPoints: {
    outstanding: { $inc: 200 },
    total: { $inc: 200 }
  }
};
 
patch(document, documentPatch);
> {
  name: 'Dan Scanlon',
  grade: 7,
  country: 'USA',
  school: 'SAHS',
  state: 'PA',
  rewardPoints: {
    outstanding: 800,
    total: 12200,
    monthly: []
  }
}

Install

npm i object-patch

DownloadsWeekly Downloads

0

Version

1.0.3

License

Apache

Last publish

Collaborators

  • avatar