https://github.com/fritzy/level-2i
Secondary indexes for leveldb.
https://github.com/fritzy/level-2i
Last synced: about 2 months ago
JSON representation
Secondary indexes for leveldb.
- Host: GitHub
- URL: https://github.com/fritzy/level-2i
- Owner: fritzy
- Created: 2014-06-23T18:15:29.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2015-01-11T06:17:48.000Z (almost 11 years ago)
- Last Synced: 2025-08-09T09:50:46.790Z (2 months ago)
- Language: JavaScript
- Size: 222 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
#Level-2i, Secondary Indexes for Level
Creates and manages indexes and totals for your keys atomically, allowing you to look up keys by their secondary indexes.
Indexes are kept up to date as you update the value.## Wrap LevelUp
```javascript
var Level2i = require('level2i');
var mydb = Level2i(levelup('/some/path'));
```## Put with indexes
```javascript
mydb.put('somekey', 'cheese', {indexes: {'name_bin': 'fritzy'}}, function (err) {
// ...
});
```## Look up indexed values
```javascript
var fritzyresults = mydb.createReadStream({index: 'name_bin', start: 'fritzy', end: 'fritzy'});
```## Find out how many indexed values you have
```
mydb.getIndexValueTotal('name_bin', 'fritzy', function (err, total) {
console.log("There are %d fritzys!" % total);
});
```## Kept up to date!
* Every put replaces the indexes with what you specify
* Deleting a key removes it from the results
* Counts are kept accurate