Skip to content

Battlefy/Viceroy-Delta

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Viceroy Delta

Viceroy Schema is a delta implementation developed for the (soon to be released) Viceroy ORM.

Designed as a standalone package to allow anyone to create and apply deltas without needing an entire ORM.

Use it with node or in the browser using browserify.

npm install viceroy-delta

NPM version

Browser Support

Example

var delta = require('viceroy-delta');

// create an old version of a person record
var oldRecord = {
  name: {
    first: 'John',
    last: 'Doe'
  },
  born: new Date('Jan 23, 1981'),
  sex: 'M'
};

// create an new version of a person record
var newRecord = {
  name: {
    first: 'Johnny',
    last: 'Doe'
  },
  born: new Date('Jan 24, 1981'),
  sex: 'M'
};

// create a delta from the old and new copy of the record
var delta = delta.create(oldRecord, newRecord);

// lets look at the diff
delta.diff => {
  $set: {
    'name.first': 'Johnny',
    born: Sat Jan 24 1981 00:00:00 GMT-0800 (PST)
  }
};

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors