level-idx
High Level leveldb indexing API using level-auto-index.
npm install level-idx
Usage
Index posts by title and body length, then query for them:
var Index = var level = var sub = var db = var posts = var idx = Indexposts idx var post = title: 'a title' body: 'lorem ipsum' author: 'julian' posts
API
Index(db, idb)
Index db
into idb
.
Index#by(name, props)
Create an index called name
and index by props
.
props
should be a string or an array of strings that each name a property.
Deep object access is enabled via
deep-access. Use multiple
properties if you can't guarantee the uniqueness of the first property's
value.
If a property doesn't exist, e.g. if you want to index by body.length
but there is no key body
, it will be ignored.
Index.db
The underlying db
.
Index.db.by{Name}.get(key[, opts], fn)
Index.db.by{Name}.create{Key,Value,Read}Stream([opts])
See level-auto-index.
Multilevel
Populate db.methods
with the manifests of each indexed db.object
:
var index = ;var createManifest = ; dbmethods = {};dbposts = db;dbmethodsposts = type: 'object' methods: methods;
See Also
This module is a port of juliangruber/level-sec that works/uses subleveldown and level-auto-index.