{"id":15824397,"url":"https://github.com/will123195/levelgo","last_synced_at":"2025-04-01T08:53:25.137Z","repository":{"id":140395283,"uuid":"256945578","full_name":"will123195/levelgo","owner":"will123195","description":"Indexed collections for LevelDB (inspired by MongoDB)","archived":false,"fork":false,"pushed_at":"2020-05-19T21:24:00.000Z","size":107,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-06T08:41:44.373Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/will123195.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2020-04-19T08:01:42.000Z","updated_at":"2023-03-08T04:34:56.000Z","dependencies_parsed_at":"2024-02-06T02:02:39.692Z","dependency_job_id":null,"html_url":"https://github.com/will123195/levelgo","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/will123195%2Flevelgo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/will123195%2Flevelgo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/will123195%2Flevelgo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/will123195%2Flevelgo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/will123195","download_url":"https://codeload.github.com/will123195/levelgo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246612494,"owners_count":20805354,"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":[],"created_at":"2024-10-05T08:41:47.916Z","updated_at":"2025-04-01T08:53:25.119Z","avatar_url":"https://github.com/will123195.png","language":"JavaScript","readme":"# levelgo\n\nIndexed collections for LevelDB (inspired by MongoDB)\n\n[![Build Status](https://travis-ci.org/will123195/levelgo.svg?branch=master)](https://travis-ci.org/will123195/levelgo)\n\n## Install\n\n```\nnpm i levelgo\n```\n\n## Example\n\n```js\nimport levelgo from 'levelgo'\n\nconst db = levelgo('example-db')\n\ndb.collection('books')  \ndb.books.registerIndex({ author: 1 })\n\nawait db.books.put('book1', { \n  author: 'Hemingway', \n  title: 'Islands in the Stream',\n  year: 1970\n})\n\nconst book = await db.books.get('book1')\nconst books = await db.books.find({ author: 'Hemingway' })\n```\n\n## API\n\n#### \u003ccode\u003edb = levelgo( location )\u003c/code\u003e\n- `location` {String} path of the LevelDB location to be opened, or in browsers, the name of the IDBDatabase to be opened\n\n#### \u003ccode\u003edb.collection( name )\u003c/code\u003e\n- `name` {String} name of the collection to initialize\n\n## Collection methods\n\n#### \u003ccode\u003edb.*name*.del( id )\u003c/code\u003e\n- `id` {String|Number} primary key of the value to delete\n\n#### \u003ccode\u003edb.*name*.find( [query] )\u003c/code\u003e\n- `query` {Object} optional selection filter. An index with the same fields must be registered. If blank or empty object, returns all values in the collection.\n\n- Mongo-style comparison query operators are available:\n    - `$gt`\n    - `$lt`\n    - `$gte`\n    - `$lte`\n    - `$in`\n    - `$nin`\n    - `$eq`\n    - `$ne`\n\n- Note: `null`, `undefined` and \"empty string\" values are indexed the same as \"blank\" values.\n\n#### \u003ccode\u003edb.*name*.findKeys( [query] )\u003c/code\u003e\n- `query` {Object} optional selection filter. An index with the same fields must be registered. If blank or empty object, returns all keys (ids) in the collection.\n\n#### \u003ccode\u003edb.*name*.get( id )\u003c/code\u003e\n- `id` {String|Number} primary key of the value to retrieve\n\n#### \u003ccode\u003edb.*name*.put( id, value )\u003c/code\u003e\n- `id` {String|Number} primary key of the value to store\n- `value` {mixed} any stringify-able value to store in the collection\n\n#### \u003ccode\u003edb.*name*.registerIndex( fields )\u003c/code\u003e\n- `fields` {Object} fields to be indexed. Always set the value of each field to `1` since only ascending indices are currently supported.\n\n### Atomic Batch\n\n#### `batch = db.batch()`\n#### \u003ccode\u003ebatch.*name*.del( id )\u003c/code\u003e\n#### \u003ccode\u003ebatch.*name*.put( id, value )\u003c/code\u003e\n#### `batch.write()` \n\n\n## Advanced Example\n\n```js\nimport levelgo from 'levelgo'\n\nconst db = levelgo('example-db')\n\ndb.collection('books')\n\n// you can have compound nested indices\ndb.books.registerIndex({ \n  tags: 1,\n  'reviews.stars': 1\n})\n\n// batch operations are written atomically\nconst batch = db.batch()\nbatch.books.del('book1')\nbatch.books.put('book2', { \n  author: 'Hemingway', \n  title: 'Islands in the Stream',\n  year: 1970,\n  reviews: [\n    { stars: 5, username: 'taylor' },\n    { stars: 4, username: 'river' },\n  ],\n  tags: ['classic']\n})\nawait batch.write()\n\n// find books that are tagged 'classic' that have at least one review of 4+ stars\nconst books = await db.books.find({ \n  'reviews.stars': { $gte: 4 },\n  tags: 'classic'\n})\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwill123195%2Flevelgo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwill123195%2Flevelgo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwill123195%2Flevelgo/lists"}