Giter Club home page Giter Club logo

browsercouch's Introduction

BrowserCouch

CouchDB in the browser - persistant, syncing client side storage.

Status

I'm a few weeks away from what I'd call a 'stable' release. Please feel free to fork or suggest improvements, but I'd hold off on using this in a live setting until I can get some issues ironed out.

Thanks,

Example

###GET:

var database = BrowserCouch('foo');
database.onload(function(){
    database.get('bar', function(d){console.log(d)});
});

###SYNC

database.sync('http://localhost:5984/foo', {continuous:true});

###MAP REDUCE

var test_data = [
	{_id : "0", hello : 'world'},
	{_id : "1", chunky : 'monkey'},
	{_id : "2", foo : 'bar'},
	{_id : "3", black : 'hat'},
	{_id : "4", black : 'tea'},
	{_id : "5", words : 'two foo three'},
	{_id : "6", words: 'two'}
];		

var db = BrowserCouch('bar');

db.onload(function(){
	db.put(test_data, function(){});	
});

Some time later ...

var db = BrowserCouch('bar');
db.onload(function(){
	db.view({
		map : function(doc, emit){
			if (doc.words){
				var words = doc.words.split(" ");
    			for (var i = 0; i < words.length; i++)
      				emit(words[i], 1);
      		}		
		},
		reduce : function(keys, values){
			var sum = 0;
    		for (var i = 0; i < values.length; i++)
      			sum += values[i];
    		return sum;
    	},
    	finished : function(view){
    		console.log(view.findRow('two')); // Should emit 2
    	}	
	});
});	

(See the unit tests for more examples)

browsercouch's People

Contributors

peterbraden avatar airportyh avatar mikeal avatar

Stargazers

Zack Bloom avatar

Watchers

Zack Bloom avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.