level-map-index
Another indexing solution for leveldb. Adapted from map-reduce. The API is unstable because this module is a by-product of refactoring an ugly ORM.
Jump to: api / install / license
examples
// create your databasevar sublevel = level = db = // installdb // create indicesdbindex'title'dbindex'author.name' 'price' // a custom index (should return an array)dbindex'custom' { return valuetitle} var author = name: 'bob' var book = title: 'foo' price: 10 author: author db { // streams will wait for indexing to complete // every book by bob, ordered by price db // every book by bob with a price of 10 db // ordered by title db // use sublevel hooks dbindex'custom' // this will (eventually) trigger the above post hook db}
api
index (db, [opts || fn])
Install the plugin.
db.index(props, [opts || fn])
Create an index.
db.streamBy(props, [range, opts])
Likely to change, no docs yet.
db.by(props, [range, opts], cb)
db.getBy(props, [range, opts], cb)
db.hasIndex(props)
index.start()
Manually trigger a rebuild. A complete
event fires when it's done.
install
With npm do:
npm install level-map-index