0.3.1 • Published 10 years ago

level-indico v0.3.1

Weekly downloads
3
License
-
Repository
github
Last release
10 years ago

level-indico

Create and manage indices for you leveldb database.

  • No generic query system, provides just some flexible low level methods to access indexed data. You can use those to build your custom queries.
  • Uses bytewise encoding for indices.
  • Supports automatic indexing (using hooks).
  • Works with changing fields.

NPM

Build Status

Usage

//Indico require a sublevel-enabled db
var db = indico(sublevel(level('db', { valueEncoding: 'json' }));

//set indices on a sublevel
var posts = db.sublevel('posts');

//set a single index
db.ensureIndex('title');
db.ensureIndex('commentCount');
//set a compound index
db.ensureIndex('title', 'commentCount');

//[...] Put some data

//Now query...

//Find all all posts having title = "Hello"
db.findBy(['title'], {start: ['Hello'], end: ['Hello']}, function (err, data) {
  //...
});

//Find all all posts having title = "Hello" AND commentCount >= "1"
db.findBy(['title', 'commentCount'], {start: ['Hello', 1], end: ['Hello', undefined]}, function (err, data) {
  //...
});

//Get all posts sorted by commentCount desc
db.findBy(['commentCount'], {start: [null], end: [undefined]}, function (err, data) {
  //...
});

//Streaming version
db.streamBy(['commentCount'], {start: [null], end: [undefined]})
.on('data', function(data) {
//...
})
.on('close, function() {
//...
})

...More to come

0.3.1

10 years ago

0.3.0

11 years ago

0.2.0

11 years ago

0.1.4

11 years ago

0.1.3

11 years ago

0.1.2

11 years ago

0.1.1

11 years ago

0.1.0

11 years ago