Skip to content

Instantly share code, notes, and snippets.

@dscape
Last active December 11, 2015 09:29
Show Gist options
  • Save dscape/6910c2fec43e4f057138 to your computer and use it in GitHub Desktop.
Save dscape/6910c2fec43e4f057138 to your computer and use it in GitHub Desktop.
var db_name = 'hackaton_' + (~~(Math.random() * 1e9)).toString(36);
Pouch('idb://'+db_name, function (err, db) {
if(err) {
return console.log('yay all live coding things fail right?');
}
var pouch=db;
pouch.put({_id: '1', bar: 'baz'}, function () {
pouch.get('1', function (err, doc) { console.log(doc); });
Pouch.replicate('idb://' + db_name, 'http://localhost:2020/foobar2003', function(err, changes) {
console.log('omg hi!');
console.log('got changes', changes);
});
});
});
var db_name = 'hackaton_' + (~~(Math.random() * 1e9)).toString(36);
var pouch;
Pouch('idb://'+db_name, function (err, db) {
pouch=db;
})
pouch.put({_id: '1', bar: 'baz'});
pouch.get('1', function (err, doc) { console.log(doc); })
Pouch.replicate('idb://' + db_name, 'http://localhost:2020/foobar2003', function(err, changes) {
console.log('omg hi!')
console.log('got changes', changes);
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment