<commit_before>
# Hive
    
	The missing node.js stack: automated.

## Installation

    $ npm install hive

## v0.1 Features [in development, watch this repo and check back for v0.1]

###Create

	$ hive create hello-world at ~/projects on :80
	> Your project is running at http://hello-world.dev:80
	> See your tests fail by running hive test hello-world
	
###Model
	var pic   = new hive.File('images/pic.jpg'),
		model = new hive.Model({watch: pic});

	//Tell the response to watch the model. It will automatically render a view or return JSON.
	res.watch(model);

	pic.fetch(function(err, data) {
		data = someCompressFunction(data);
		pic.save(data);
		model.set({contents: data, file: pic.path});
		model.save();
	});


###Persist
Hive supports several persistence layers out of the box:

* Redis Cache
	
	Hive automatically caches model reads and writes and staggers load to the database, making Hive apps crazy fast right out of the box.
	
* MongoDB

	After models are placed in a pending Redis queue they are saved to a Mongo Database for persistence.

###Authenticate
Hive installs with a simple Redis based session and user management system baked in. Registration, remember me, forgot password, login? Yep.

	var user = new hive.User('<EMAIL>', 'password');
	res.watch(user); //The result of the success or error callback will automatically be sent as JSON to the response
	user.save();

###Query
Hive provides query modeling for high performance database queries:

	app.get('/latest', function(req,res) {
		//Find the latest 100 objects in the entire database
		var query = new hive.Query({type: '*', sortby: 'id', asc: true, limit: 100});
		//If views/latest.haml exists, the success or error will be sent to the view
		res.watch(query);
		//The result of this query will be cached
		//Default caching behavior can be overriden by extending Query
		query.fetch();
		setTimeout(function() {
			//After 30 seconds, manually remove from cache
			query.destroy();
		}, 30000);
	});

Hive can also automatically create queries on the database server.
The following will be all run on the database server.

	var ActiveUsersQuery = hive.Query.extend({
		stored: function(result, db) {
		   m = function() { emit(this.uid, 1); }
		   r = function(k,vals) { return 1; }
		   return db.events.mapReduce(m, r, { query : {type: 'logins'} });
		}
	});

	app.get('/users/active', function(req,res) {
		var users = new ActiveUsersQuery();
		res.watch(users);
		users.fetch();
	});


## Compatibility

Hive is compatible with node 0.4.x

## License 

(The MIT License)

Copyright (c) 2011 <NAME>

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the<commit_msg>Readme updates<commit_after>
# Hive 

Automate your nodejs development.    

*Version 0.0.1*

## Installation

    $ npm install hive

## v0.1 Features 

_note: v0.1 is in development, watch this repo and check back for 0.1 at the top_

###Create

	$ hive create hello-world at ~/projects on :80
	> Your project is running at http://hello-world.dev:80
	
###Model

Hive makes modeling data easy. Whether it is a database document, a file, a tweet, or any other piece of data.

	//Opening a file doesn't involve nested callbacks
	var pic   = new hive.File('images/pic.jpg'),
		model = new hive.Model({watch: pic});
	//Tell the response what to care about, and it does the rest
	res.watch(model);
	pic.fetch(function(err, data) {
		pic.save(data);
		model.set({contents: data, file: pic.path});
		model.save();
	});


###Persist

Hive supports several persistence layers out of the box.

* Redis Cache
* MongoDB

###Authenticate

Registration, remember me, forgot password, login? Yep.

	var user = new hive.User('<EMAIL>', 'password');
	res.watch(user);
	user.save();

###Query

Quickly model queries that automatically are cached.

	app.get('/latest', function(req,res) {
		//Find the latest 100 objects in the entire database
		var query = new hive.Query({type: '*', sortby: 'created', asc: false, limit: 100});
		//If views/latest.haml exists, the success or error will be sent to the view
		res.watch(query);
		//The result of this query will be cached
		query.fetch();
		if(query.isFromCache) {
			setTimeout(function() {
				//After 30 seconds, manually remove from cache
				query.destroy();
			}, 30000);
		}
	});

Hive can also automatically create queries on the database server.

	var ActiveUsersQuery = hive.Query.extend({
		stored: function(result, db) {
		   m = function() { emit(this.uid, 1); }
		   r = function(k,vals) { return 1; }
		   return db.events.mapReduce(m, r, { query : {type: 'login', limit: 25} });
		}
	});

	app.get('/users/active', function(req,res) {
		var users = new ActiveUsersQuery();
		//Shorthand for res.watch()
		res.watch(users.fetch());
	});


## Compatibility

Hive is compatible with node 0.4.x

## License 

(The MIT License)

Copyright (c) 2011 <NAME>

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
{'fraction_non_alphanumeric': 0.11612776025236593, 'fraction_numerical': 0.012815457413249211, 'mean_word_length': 3.75, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1611160', 'n_tokens_mistral': 1692, 'n_tokens_neox': 1535, 'n_words': 610}