0.12.1 • Published 5 years ago

clever v0.12.1

Weekly downloads
176
License
-
Repository
github
Last release
5 years ago

Clever Javascript Library

Build Status

Installation

Via npm:

npm install clever

Usage

Clever = require('clever');
var clever = Clever({token: 'YOUR_BEARER_TOKEN'});

If you'd like to play around with our test data, please use the token: DEMO_TOKEN. See our developer guide for more information.

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. The available methods are find, findOne, and findById:

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:

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

Query objects also support a stream interface for auto-pagination:

// pull sections 10 at a time
var count = 0;
var stream = clever.Section.find().limit(10).stream();
stream.on('data', function(section) {
  count += 1;
  assert(section instanceof clever.Section);
});
stream.on('end', function() {
  console.log(count, 'sections loaded');
});

Feedback

Questions, feature requests, or feedback of any kind is always welcome! We're available at tech-support@clever.com.

0.12.1

5 years ago

0.12.0

5 years ago

0.11.1

7 years ago

0.11.0

9 years ago

0.9.0

10 years ago

0.8.0

10 years ago

0.6.6

10 years ago

0.6.4

10 years ago

0.6.3

10 years ago

0.6.2

10 years ago

0.6.1

10 years ago

0.6.0

10 years ago

0.5.7

10 years ago

0.5.5

10 years ago

0.5.3

11 years ago

0.4.3

11 years ago

0.4.2

11 years ago

0.4.1

11 years ago

0.4.0

11 years ago

0.3.0

11 years ago

0.2.3

11 years ago

0.2.2

11 years ago

0.2.1

11 years ago

0.2.0

11 years ago

0.1.18

11 years ago

0.1.17

11 years ago

0.1.16

11 years ago

0.1.15

12 years ago

0.1.14

12 years ago

0.1.13

12 years ago

0.1.12

12 years ago

0.1.11

12 years ago

0.1.10

12 years ago

0.1.9

12 years ago

0.1.8

12 years ago

0.1.7

12 years ago

0.1.6

12 years ago

0.1.5

12 years ago

0.1.4

12 years ago

0.1.3

12 years ago

0.1.1

12 years ago

0.1.0

12 years ago

0.0.7

12 years ago

0.0.6

12 years ago

0.0.4

12 years ago

0.0.3

12 years ago

0.0.2

12 years ago

0.0.1

12 years ago