# level-indexing

> level indexing and finding

Latest version **0.3.0** (published 2013-11-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install level-indexing
pnpm add level-indexing
yarn add level-indexing
bun add level-indexing
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.0 |
| Published | 2013-11-22 |
| First published | 2013-11-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | * |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | stagas |
| Maintainers | stagas |
| Keywords | level, levelup, leveldb, index, indexes, indexing, find, finding |

## Links

- npm: https://www.npmjs.com/package/level-indexing
- Repository: https://github.com/stagas/level-indexing
- Issues: https://github.com/stagas/level-indexing/issues
- npm.io page: https://npm.io/package/level-indexing

## Recent versions

- 0.3.0 (latest) — 2013-11-22
- 0.2.2 — 2013-11-21
- 0.2.1 — 2013-11-21
- 0.2.0 — 2013-11-20
- 0.1.0 — 2013-11-20
- 0.0.1 — 2013-11-19

## README

# level-indexing

level indexing and finding

## Installing

`npm install level-indexing`

## Example

```js
var assert = require('assert');

var level = require('level');
var sublevel = require('sublevel');
var indexing = require('level-indexing');

// sublevel instance
var db = sublevel(level('./level-test'));

// users sublevel (needs json value encoding)
var users = db.sublevel('users', { valueEncoding: 'json' });

// use indexing
indexing(users);

// index some properties
users
.index('username')
.index('email');

// a user object
var user = {
  id: 1,
  username: 'foobar',
  email: 'foo@bar'
};

users.put(user.id, user, function(err){
  // properties are now indexed
  users.by('username', 'foobar', function(err, value){
    assert.deepEqual(user, value);
  });

  users.byEmail('foo@bar', function(err, value){
    assert.deepEqual(user, value);
  });

  users.find(1, function(err, value){
    assert.deepEqual(user, value);
  });

  users.find('foobar', function(err, value){
    assert.deepEqual(user, value);
  });

  users.find('foo@bar', function(err, value){
    assert.deepEqual(user, value);
  });
});
```

## API

### indexing(sublevel)

Enable indexing on a sublevel db instance.

### index(name)

Indexes a property `name`.

### by(index, key, fn)

Gets a value from `index` by `key`. Key can be
an object with a property of `index`.

### find(key, fn)

Finds `key` in all indexes. Key can be an object.

## License

MIT

---
_Source: https://npm.io/package/level-indexing · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
