{"id":15497500,"url":"https://github.com/bcomnes/level-idx","last_synced_at":"2025-12-16T00:20:42.086Z","repository":{"id":57153974,"uuid":"78295295","full_name":"bcomnes/level-idx","owner":"bcomnes","description":"Another high-level API for creating secondary leveldb indexes","archived":false,"fork":false,"pushed_at":"2020-07-17T18:59:36.000Z","size":37,"stargazers_count":14,"open_issues_count":1,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-29T19:34:28.451Z","etag":null,"topics":["indexing","leveldb","nodejs"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bcomnes.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-01-07T18:11:54.000Z","updated_at":"2022-07-12T19:13:42.000Z","dependencies_parsed_at":"2022-09-05T15:41:48.528Z","dependency_job_id":null,"html_url":"https://github.com/bcomnes/level-idx","commit_stats":null,"previous_names":["hypermodules/level-idx"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bcomnes%2Flevel-idx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bcomnes%2Flevel-idx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bcomnes%2Flevel-idx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bcomnes%2Flevel-idx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bcomnes","download_url":"https://codeload.github.com/bcomnes/level-idx/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250333886,"owners_count":21413472,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["indexing","leveldb","nodejs"],"created_at":"2024-10-02T08:38:55.558Z","updated_at":"2025-12-16T00:20:42.029Z","avatar_url":"https://github.com/bcomnes.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# level-idx\n\nHigh Level leveldb indexing API using [level-auto-index](https://github.com/hypermodules/level-auto-index).\n\n```bash\nnpm install level-idx\n```\n\n[![level badge][level-badge]](https://github.com/level/awesome)\n[![npm][npm-image]][npm-url]\n[![Build Status](https://travis-ci.org/hypermodules/level-idx.svg?branch=master)](https://travis-ci.org/hypermodules/level-idx)\n[![dependencies Status](https://david-dm.org/hypermodules/level-idx/status.svg)](https://david-dm.org/hypermodules/level-idx)\n[![devDependencies Status](https://david-dm.org/hypermodules/level-idx/dev-status.svg)](https://david-dm.org/hypermodules/level-idx?type=dev)\n\n[level-badge]: https://camo.githubusercontent.com/1bd15320a5fad1db168bba8bcedb098735f82464/68747470733a2f2f6c6576656c6a732e6f72672f696d672f62616467652e737667\n[npm-image]: https://img.shields.io/npm/v/level-idx.svg\n[npm-url]: https://www.npmjs.com/package/level-idx\n\n## Usage\n\nIndex posts by title and body length, then query for them:\n\n```js\nvar Index = require('level-idx')\nvar level = require('memdb')\nvar sub = require('subleveldown')\n\nvar db = level()\nvar posts = sub(db, 'posts', {valueEncoding: 'json'})\nvar idx = sub(db, 'idx')\n\nIndex(posts, idx)\n  .by('Title', 'title')\n  .by('Length', ['body.length', 'title'])\n  .by('Author', ['author', 'title'])\n\nvar post = {\n  title: 'a title',\n  body: 'lorem ipsum',\n  author: 'julian'\n}\n\nposts.put('1337', post, function (err) {\n  if (err) throw err\n\n  posts.byTitle.get('a title', console.log)\n  posts.byLength.get('11!a title', console.log)\n  posts.byAuthor.get('julian!a title', console.log)\n})\n```\n\n## API\n\n### Index(db, idb)\n\nIndex `db` into `idb`.\n\n### Index#by(name, props)\n\nCreate an index called `name` and index by `props`.\n\n`props` should be a string or an array of strings that each name a property.\nDeep object access is enabled via\n[deep-access](https://github.com/juliangruber/deep-access). Use multiple\nproperties if you can't guarantee the uniqueness of the first property's\nvalue.\n\nIf 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.\n\n### Index.db\n\nThe underlying `db`.\n\n### Index.db.by{Name}.get(key[, opts], fn)\n### Index.db.by{Name}.create{Key,Value,Read}Stream([opts])\n\nSee [level-auto-index](https://github.com/hypermodules/level-auto-index).\n\n## Multilevel\n\nPopulate `db.methods` with the manifests of each indexed db.`object`:\n\n```js\nvar index = require('level-idx');\nvar createManifest = require('level-manifest');\n\ndb.methods = {};\ndb.posts = index(db.sublevel('posts'))\n  .by('Slug', ['slug'])\n  .db;\ndb.methods.posts = {\n  type: 'object',\n  methods: createManifest(db.posts).methods\n};\n```\n\n## See Also\n\n- [hypermodules/level-hookdown](https://github.com/hypermodules/level-hookdown) - Simple levelup hooks implemented using instance method override of arbitrary levelups.\n- [hypermodules/level-auto-index](https://github.com/hypermodules/level-auto-index) - Automatic secondary indexing for leveldb and subleveldown leveraging `level-hookdown`.\n\nThis module is a port of [juliangruber/level-sec](https://github.com/juliangruber/level-sec) that works/uses [subleveldown](http://ghub.io/subleveldown) and [level-auto-index](http://ghub.io/level-auto-index).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbcomnes%2Flevel-idx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbcomnes%2Flevel-idx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbcomnes%2Flevel-idx/lists"}