{"id":18573919,"url":"https://github.com/basedwon/index","last_synced_at":"2025-05-15T23:34:13.469Z","repository":{"id":198806008,"uuid":"701572403","full_name":"basedwon/index","owner":"basedwon","description":"A comprehensive indexing solution built to cater to a wide variety of indexing requirements.","archived":false,"fork":false,"pushed_at":"2023-11-07T11:25:17.000Z","size":20,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-19T03:56:33.528Z","etag":null,"topics":["database","indexing","inverted-index"],"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/basedwon.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"docs/contributing.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-10-07T00:24:33.000Z","updated_at":"2024-02-19T01:15:27.000Z","dependencies_parsed_at":"2023-11-07T12:29:38.265Z","dependency_job_id":"72c04697-64df-4b82-a318-4f18fb1c6477","html_url":"https://github.com/basedwon/index","commit_stats":null,"previous_names":["basedwon/index"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/basedwon%2Findex","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/basedwon%2Findex/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/basedwon%2Findex/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/basedwon%2Findex/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/basedwon","download_url":"https://codeload.github.com/basedwon/index/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254442349,"owners_count":22071863,"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":["database","indexing","inverted-index"],"created_at":"2024-11-06T23:13:23.182Z","updated_at":"2025-05-15T23:34:13.432Z","avatar_url":"https://github.com/basedwon.png","language":"JavaScript","readme":"# Indexer\n\n[![npm](https://img.shields.io/npm/v/@plaindb/index?style=flat\u0026logo=npm)](https://www.npmjs.com/package/@plaindb/index)\n[![pipeline](https://gitlab.com/frenware/framework/plaindb/index/badges/master/pipeline.svg)](https://gitlab.com/frenware/framework/plaindb/index/-/pipelines)\n[![license](https://img.shields.io/npm/l/@plaindb/index)](https://gitlab.com/frenware/framework/plaindb/index/-/blob/master/LICENSE)\n[![downloads](https://img.shields.io/npm/dw/@plaindb/index)](https://www.npmjs.com/package/@plaindb/index) \n\n[![Gitlab](https://img.shields.io/badge/Gitlab%20-%20?logo=gitlab\u0026color=%23383a40)](https://gitlab.com/frenware/framework/plaindb/index)\n[![Github](https://img.shields.io/badge/Github%20-%20?logo=github\u0026color=%23383a40)](https://github.com/basedwon/index)\n[![Twitter](https://img.shields.io/badge/@basdwon%20-%20?logo=twitter\u0026color=%23383a40)](https://twitter.com/basdwon)\n[![Discord](https://img.shields.io/badge/Basedwon%20-%20?logo=discord\u0026color=%23383a40)](https://discordapp.com/users/basedwon)\n\nA comprehensive indexing solution built to cater to a wide variety of indexing requirements. It provides a robust API for adding, removing, updating, and finding data based on multiple types of index fields. Including an inverted-indexing of words within a text field.\n\n## Features\n\n- Dynamic field creation for indexing\n- Supports single, multi, and text-based fields\n- Extensible with custom index field types\n- Asynchronous API support\n- Transactional batch operations\n- Formatter and reducer customization\n\n## Installation\n\nInstall the package with:\n\n```bash\nnpm install @plaindb/index\n```\n\n## Usage\n\nFirst, import the `Indexer` library.\n\n```js\nimport Indexer from '@plaindb/index'\n```\nor\n```js\nconst Indexer = require('@plaindb/index')\n```\n\n### Initialize the Index\n\n```js\nconst storage = // Your storage instance\nconst index = new Index(storage, ['name', 'age|gender', 'description text'])\n```\n\n### Adding an Entity\n\n```js\nawait index.add({\n  id: 1,\n  name: 'John',\n  age: 30,\n  gender: 'male',\n  description: 'Software Engineer'\n})\n```\n\n### Removing an Entity\n\n```js\nawait index.remove({\n  id: 1\n})\n```\n\n### Updating an Entity\n\n```js\nawait index.update(oldEntity, newEntity)\n```\n\n### Finding Entities\n\nYou can find entities based on index fields:\n\n```js\nconst results = await index.find('age', 30)\n```\n\n### Custom Formatter and Reducer\n\nYou can provide custom formatter and reducer functions through the `opts` parameter:\n\n```js\nconst index = new Index(storage, ['name'], {\n  formatter: new CustomFormatter(),\n  reducer: (entity) =\u003e entity.customId\n})\n```\n\n## Documentation\n\n- [API Reference](/docs/api.md)\n\n### Classes\n\n- `Index`: Manages multiple index fields and dispatches operations.\n- `IndexFactory`: Creates index fields dynamically.\n- `IndexField`: Abstract class for index fields.\n- `SingleIndexField`: Index field for single properties.\n- `MultiIndexField`: Index field for multi-properties.\n- `TextIndexField`: Index field for text-based searching.\n\n### Methods\n\n- `Index.by(slug)`: Dynamically add an index field.\n- `Index.add(entity)`: Add an entity to the index.\n- `Index.remove(entity)`: Remove an entity from the index.\n- `Index.update(oldEntity, newEntity)`: Update an entity in the index.\n- `Index.find(query, ...values)`: Find entities based on a query.\n\n## Extending\n\nTo extend the library with a custom index field, create a class extending `IndexField` and register it via `Registry`.\n\n## Tests\n\nIn order to run the test suite, simply clone the repository and install its dependencies:\n\n```bash\ngit clone https://gitlab.com/frenware/framework/plaindb/index.git\ncd indexer\nnpm install\n```\n\nTo run the tests:\n\n```bash\nnpm test\n```\n\n## Contributing\n\nThank you! Please see our [contributing guidelines](/docs/contributing.md) for details.\n\n## Donations\n\nIf you find this project useful and want to help support further development, please send us some coin. We greatly appreciate any and all contributions. Thank you!\n\n**Bitcoin (BTC):**\n```\n1JUb1yNFH6wjGekRUW6Dfgyg4J4h6wKKdF\n```\n\n**Monero (XMR):**\n```\n46uV2fMZT3EWkBrGUgszJCcbqFqEvqrB4bZBJwsbx7yA8e2WBakXzJSUK8aqT4GoqERzbg4oKT2SiPeCgjzVH6VpSQ5y7KQ\n```\n\n## License\n\n@plaindb/index is [MIT licensed](https://gitlab.com/frenware/framework/plaindb/index/-/blob/master/LICENSE).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbasedwon%2Findex","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbasedwon%2Findex","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbasedwon%2Findex/lists"}