{"id":15007863,"url":"https://github.com/baby-bitcoin/butterfly","last_synced_at":"2026-01-22T20:09:00.749Z","repository":{"id":257789442,"uuid":"860860995","full_name":"Baby-Bitcoin/butterfly","owner":"Baby-Bitcoin","description":"The smallest in-memory database software in the world.","archived":false,"fork":false,"pushed_at":"2024-09-26T22:43:50.000Z","size":58,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-02T08:42:01.384Z","etag":null,"topics":["database","db","fast","in-memory","json","lightweight","minimal","node","nodejs","redis"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/butterfly.js","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Baby-Bitcoin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"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":"2024-09-21T11:11:37.000Z","updated_at":"2024-09-26T22:43:54.000Z","dependencies_parsed_at":null,"dependency_job_id":"dbea9769-f7b1-44d3-a2d4-ee6e4a5b29b4","html_url":"https://github.com/Baby-Bitcoin/butterfly","commit_stats":null,"previous_names":["baby-bitcoin/butterfly"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Baby-Bitcoin%2Fbutterfly","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Baby-Bitcoin%2Fbutterfly/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Baby-Bitcoin%2Fbutterfly/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Baby-Bitcoin%2Fbutterfly/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Baby-Bitcoin","download_url":"https://codeload.github.com/Baby-Bitcoin/butterfly/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238968337,"owners_count":19560586,"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","db","fast","in-memory","json","lightweight","minimal","node","nodejs","redis"],"created_at":"2024-09-24T19:14:13.321Z","updated_at":"2025-10-30T12:31:31.866Z","avatar_url":"https://github.com/Baby-Bitcoin.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🦋 butterfly.js\n\nThe smallest in-memory database software in the world.\n\n## Features\n\n- Lightweight and fast JSON in-memory database (2.66KB minified).\n- Works with JSON out of the box (100% JSON data structure support).\n- Persistent storage using NDJSON log files.\n- Support for multiple indexes.\n- CRUD operations and basic search capabilities.\n\n## Installation\n\n1. Clone the repository:\n    ```bash\n    git clone https://github.com/Baby-Bitcoin/butterfly.git\n    ```\n\n2. Navigate to the project directory and install dependencies:\n    ```bash\n    npm install\n    ```\n\n3. Start it\n    ```bash\n    npm run start\n    ```\n\n## Usage\n\n### Adding and Managing Complex Objects\n\n```js\nconst { butterfly, db } = require('./butterfly.js'); // Adjust path if necessary\n\n(async () =\u003e {\n    // Adding a complex user object\n    const complexUser = {\n        id: 1,\n        name: \"John Doe\",\n        email: \"john@example.com\",\n        address: {\n            street: \"123 Main St\",\n            city: \"Springfield\",\n            state: \"IL\",\n            postalCode: \"62704\"\n        },\n        preferences: {\n            theme: \"dark\",\n            notifications: true\n        },\n        roles: [\"admin\", \"editor\"]\n    };\n    \n    await db.setKey(butterfly.INDEX_2, 'user_1', complexUser);\n\n    // Retrieving and updating complex objects\n    const retrievedUser = await db.getKey(butterfly.INDEX_2, 'user_1');\n    retrievedUser.preferences.theme = \"light\"; // Update a nested property\n\n    await db.setKey(butterfly.INDEX_2, 'user_1', retrievedUser); // Save the updated user object\n})();\n```\n\n### Working with Products and Orders\n\n```js\nconst product = {\n    id: 101,\n    name: \"Wireless Headphones\",\n    description: \"Noise-cancelling over-ear headphones with Bluetooth connectivity.\",\n    price: 299.99,\n    stock: 150,\n    categories: [\"Electronics\", \"Audio\"],\n    specifications: {\n        batteryLife: \"30 hours\",\n        weight: \"250g\",\n        color: \"Black\"\n    }\n};\n\nawait db.setKey(butterfly.INDEX_3, 'product_101', product);\n\n// Creating and managing an order object\nconst order = {\n    id: 5001,\n    userId: 1,\n    products: [\n        { productId: 101, quantity: 2 },\n        { productId: 102, quantity: 1 }\n    ],\n    totalAmount: 599.97,\n    status: \"Processing\"\n};\n\nawait db.setKey(butterfly.INDEX_4, 'order_5001', order);\n```\n\n### Searching and Filtering Data\n\n```js\n// Searching for products that have 'Bluetooth' in the description\nconst searchResults = await db.searchKeys(butterfly.INDEX_3, \"Bluetooth\");\nconsole.log(\"Search Results:\", searchResults);\n```\n\n### Generating New IDs\n\n```js\n// Generating a new ID for a product\nconst newProductId = await db.getNewID(butterfly.INDEX_3);\nconsole.log(\"New Product ID:\", newProductId);\n```\n\n\n### Contributing\n\nContributions are welcome! If you have ideas for improvements or new features, please open an issue or submit a pull request.\n\n\n### License\nThis project is licensed under the GNU General Public License v3.0. See the LICENSE file for more details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbaby-bitcoin%2Fbutterfly","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbaby-bitcoin%2Fbutterfly","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbaby-bitcoin%2Fbutterfly/lists"}