<commit_before># Clever Javascript Library

[![Build Status](https://secure.travis-ci.org/Clever/clever-js.png)](http://travis-ci.org/Clever/clever-js)

## Installation

Via npm:

```bash
npm install clever
```

## Usage

```javascript
Clever = require('clever');
var clever = Clever('YOUR_API_KEY');
```

The `clever` package exposes objects corresponding to resources:

* District
* School
* Section
* Student
* Teacher
* Event

Each exposes a query API that closely resembles that of [Mongoose](http://mongoosejs.com/docs/queries.html). The available methods are `find`, `findOne`, and `findById`:

```javascript
clever.api_key = 'DEMO_KEY';

clever.District.find({}, function(error, districts) {
  assert(Array.isArray(districts));
  assert(districts[0] instanceof clever.District);
  assert.equal(district.get('name'), 'Demo District');
});

clever.School.findOne({ name: "Clever Academy" }, function(error, school) {
  assert(school instanceof clever.School);
  assert.equal(school.get('name'), 'Clever Academy');
});

clever.School.findById('4fee004cca2e43cf27000001', function(error, school) {
  assert(school instanceof clever.School);
  assert.equal(school.get('name'), 'Clever Academy');
});
```

When no callback is passed, the methods return a query object that allows you to build up a query over time:

```javascript
clever.School
.find()
.where('name').equals('Clever Academy')
.exec(callback);
```

Query objects also support a [stream](http://nodejs.org/api/stream.html) interface for auto-pagination:
<commit_msg>update readme for new clever object setup<commit_after># Clever Javascript Library

[![Build Status](https://secure.travis-ci.org/Clever/clever-js.png)](http://travis-ci.org/Clever/clever-js)

## Installation

Via npm:

```bash
npm install clever
```

## Usage

```javascript
Clever = require('clever');
var clever = Clever('YOUR_API_KEY');
```

The `clever` package exposes objects corresponding to resources:

* District
* School
* Section
* Student
* Teacher
* Event

Each exposes a query API that closely resembles that of [Mongoose](http://mongoosejs.com/docs/queries.html). The available methods are `find`, `findOne`, and `findById`:

```javascript
clever.District.find({}, function(error, districts) {
  assert(Array.isArray(districts));
  assert(districts[0] instanceof clever.District);
  assert.equal(district.get('name'), 'Demo District');
});

clever.School.findOne({ name: "Clever Academy" }, function(error, school) {
  assert(school instanceof clever.School);
  assert.equal(school.get('name'), 'Clever Academy');
});

clever.School.findById('4fee004cca2e43cf27000001', function(error, school) {
  assert(school instanceof clever.School);
  assert.equal(school.get('name'), 'Clever Academy');
});
```

When no callback is passed, the methods return a query object that allows you to build up a query over time:

```javascript
clever.School
.find()
.where('name').equals('Clever Academy')
.exec(callback);
```

Query objects also support a [stream](http://nodejs.org/api/stream.html) interface for auto-pagination:

{'fraction_non_alphanumeric': 0.15382103200522534, 'fraction_numerical': 0.010450685826257348, 'mean_word_length': 5.717105263157895, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '3561351', 'n_tokens_mistral': 1037, 'n_tokens_neox': 946, 'n_words': 250}