<commit_before># mongotree

Manage tree structures in MongoDB

## Getting Started
Install the module with: `npm install mongotree`

```javascript
var mongotree = require('mongotree'),
	MongoClient = require('mongodb').MongoClient,
	dsn = 'mongodb://localhost:27017/my-database';

// Create a new tree structure in a mongodb collection
MongoClient.connect(dsn, function(err, db) {
	mongotree.addTree('some/path', db.collection('my-collection'), function(err, tree) {
		console.log(tree);
		db.close();
	});
});
```<commit_msg>added more examples to readme<commit_after># mongotree

Manage tree structures in MongoDB

## Getting Started
Install the module with: `npm install mongotree`

Create a default tree
```javascript
var mongotree = require('mongotree'),
	MongoClient = require('mongodb').MongoClient,
	dsn = 'mongodb://localhost:27017/my-database';

// Create a new tree structure in a mongodb collection
MongoClient.connect(dsn, function(err, db) {
	mongotree.addTree('products/cameras/accessories', db.collection('my-collection'), function(err, tree) {
		console.log(tree);
		db.close();
	});
});

// outputs
[ { _id: 'products', name: 'products', parent: '' },
  { _id: 'products/cameras', name: 'cameras', parent: 'products' },
  { _id: 'products/cameras/accessories',
    name: 'accessories',
    parent: 'products/cameras' } ]

```

Create a tree with custom params for nodes

```javascript
var mongotree = require('mongotree'),
	MongoClient = require('mongodb').MongoClient,
	dsn = 'mongodb://localhost:27017/my-database';

// Create a new tree structure in a mongodb collection
MongoClient.connect(dsn, function(err, db) {
	var params = {
		path: 'products/cameras/accessories',
		created: new Date()
	};
	mongotree.addTree(params, db.collection('my-collection'), function(err, tree) {
		console.log(tree);
		db.close();
	});
});

// outputs
[ { _id: 'products',
    name: 'products',
    parent: '',
    created: Fri Aug 16 2013 09:41:44 GMT-0700 (MST) },
  { _id: 'products/cameras',
    name: 'cameras',
    parent: 'products',
    created: Fri Aug 16 2013 09:41:44 GMT-0700 (MST) },
  { _id: 'products/cameras/accessories',
    name: 'accessories',
    parent: 'products/cameras',
    created: Fri Aug 16 2013 09:41:44 GMT-0700 (MST) } ]
```
{'fraction_non_alphanumeric': 0.15721877767936226, 'fraction_numerical': 0.027900797165633304, 'mean_word_length': 4.661654135338346, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '846802', 'n_tokens_mistral': 838, 'n_tokens_neox': 749, 'n_words': 193}