<commit_before>crescent
========

A convenient API for a simple JSON store.  Includes basic security roles.  Useful for setting up persistence for simple, non-concurrent apps.

Installation
------------

`npm install JAForbes/crescent`

Usage
-----

_Logging in:_

`var db = require('crescent')('admin','password')`

_List tables_

`db()`

_List records of table_

`db(tablename)()`

_Create record_

`db(tablename)({ foo: 'bar' })()`

_Modify record_

`db(tablename)(record_id)({ foo: 'baz' })()`

_Delete record_

`db(tablename)(record_id)(null)()`

_Delete table_

`db(tablename)(null)`

_Create table_

`db(tablename)({first: 'record', of: 'new table'})()`

_Navigation_

Return to current table from record with `.`:

`db(tablename)(record_id)('.')()`

Return to table list with `..`:

`db(tablename)('..')()`

_Roles and Access_

There are two roles, `'admin'` and `'user'`.

Admins can modify restricted tables and create tables.

Users can create records in existing tables.  Users can also modify records they have access too.

Records have an array `access`.

The `access` array contains the ids of users that are allowed to modify that record.

_Restricted tables_

Tables that begin with an underscore are restricted.  Only an admin can delete an underscored table.

However non admin users can modify records if that record contains an `access` array contain that users id.

_Advanced Querying using functions_

The following returns a hash of records that match the critera.

```javascript

//Equivalent to SELECT * FROM <tablename> WHERE name = 'james'
db(tablename)(function(record,id){
	return record.name == 'james'
})()

```

You can also modify data in the loop, and changes are automatically saved.

```javascript

db(tablename)(function(record,id){
	return record.copyright = new Date().getFullYear()
})()

```<commit_msg>Changed sub headings to bold from italic<commit_after>crescent
========

A convenient API for a simple JSON store.  Includes basic security roles.  Useful for setting up persistence for simple, non-concurrent apps.

Installation
------------

`npm install JAForbes/crescent`

Usage
-----

__Logging in:__

`var db = require('crescent')('admin','password')`

__List tables__

`db()`

__List records of table__

`db(tablename)()`

__Create record__

`db(tablename)({ foo: 'bar' })()`

__Modify record__

`db(tablename)(record_id)({ foo: 'baz' })()`

__Delete record__

`db(tablename)(record_id)(null)()`

__Delete table__

`db(tablename)(null)`

__Create table__

`db(tablename)({first: 'record', of: 'new table'})()`

__Navigation__

Return to current table from record with `.`:

`db(tablename)(record_id)('.')()`

Return to table list with `..`:

`db(tablename)('..')()`

__Roles and Access__

There are two roles, `'admin'` and `'user'`.

Admins can modify restricted tables and create tables.

Users can create records in existing tables.  Users can also modify records they have access too.

Records have an array `access`.

The `access` array contains the ids of users that are allowed to modify that record.

__Restricted tables__

Tables that begin with an underscore are restricted.  Only an admin can delete an underscored table.

However non admin users can modify records if that record contains an `access` array contain that users id.

__Advanced Querying using functions__

The following returns a hash of records that match the critera.

```javascript

//Equivalent to SELECT * FROM <tablename> WHERE name = 'james'
db(tablename)(function(record,id){
	return record.name == 'james'
})()

```

You can also modify data in the loop, and changes are automatically saved.

```javascript

db(tablename)(function(record,id){
	return record.copyright = new Date().getFullYear()
})()

```
{'fraction_non_alphanumeric': 0.1267718641347954, 'fraction_numerical': 0.0, 'mean_word_length': 4.727411944869831, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1931009', 'n_tokens_mistral': 1206, 'n_tokens_neox': 1165, 'n_words': 436}