Skip to content

Story: Diff two feeds #29

Description

@flyingzumwalt

This is a Work in Progress

If I run jawn.diff(feedOneId, feedTwoId) I should get a stream of json objects representing actions (add/update/delete).

If I apply all of the actions in that stream to the database/repository represented by feedOne, its contents should then match feedTwo.

Running a diff

Checkout a feed, run a diff and print the results of the diff.

var jawn = require('jawn');
var through = require('through2').obj;

var checkout = jawn.checkout(feedOneId);
checkout.on('end', function () {
  jawn.diff(feedOneId, feedTwoId).pipe(process.stdout)
});

The output should look roughly like this: (see 2015 dat beta for real examples)

{ action: "add", key: 9812349878, values: {...} }
{ action: "delete", key: 23421341234 }

Applying a diff using (hypothetical) jawn.applyActionStream function

var jawn = require('jawn');
var through = require('through2').obj;

var checkout = jawn.checkout(feedOneId);
var applyActions =  jawn.applyActionStream

checkout.on('end', function () {
  jawn.diff(feedOneId, feedTwoId).pipe(applyActions)
})

applyActions.on('end', function () {
  // the current contents of the repo should match the contents of feedTwo
  t.same('', jawn.diff(jawn.current, feedTwoId))
})

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions