{"id":22079856,"url":"https://github.com/megalithofficial/meg.db-light","last_synced_at":"2026-02-15T10:36:35.915Z","repository":{"id":219724052,"uuid":"749787991","full_name":"MegalithOfficial/meg.db-light","owner":"MegalithOfficial","description":"MegDB-light, A lightweight TypeScript database module providing a type-safe API for efficient data storage and retrieval. Easily extendable with custom drivers, including a built-in JSONDriver.","archived":false,"fork":false,"pushed_at":"2024-10-21T07:15:31.000Z","size":46,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-12T17:59:15.021Z","etag":null,"topics":["begginer-friendly","custom-driver","customisable","database","easy-to-use","fast","javascript","json","lightweight","node-js","quickdb","type-safe","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/MegalithOfficial.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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-01-29T11:57:42.000Z","updated_at":"2024-06-17T20:36:01.000Z","dependencies_parsed_at":"2024-11-30T23:11:35.629Z","dependency_job_id":"49e9baed-a8f9-45b8-912b-bc209148d1ed","html_url":"https://github.com/MegalithOfficial/meg.db-light","commit_stats":null,"previous_names":["megalithofficial/meg.db-light"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/MegalithOfficial/meg.db-light","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MegalithOfficial%2Fmeg.db-light","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MegalithOfficial%2Fmeg.db-light/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MegalithOfficial%2Fmeg.db-light/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MegalithOfficial%2Fmeg.db-light/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MegalithOfficial","download_url":"https://codeload.github.com/MegalithOfficial/meg.db-light/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MegalithOfficial%2Fmeg.db-light/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29475760,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-15T10:25:47.032Z","status":"ssl_error","status_checked_at":"2026-02-15T10:25:01.815Z","response_time":118,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["begginer-friendly","custom-driver","customisable","database","easy-to-use","fast","javascript","json","lightweight","node-js","quickdb","type-safe","typescript"],"created_at":"2024-11-30T23:11:29.308Z","updated_at":"2026-02-15T10:36:35.902Z","avatar_url":"https://github.com/MegalithOfficial.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MegDB-light: A Robust TypeScript Database Module 🚀\n\nMegDB-light is a robust, lightweight database module crafted in TypeScript. It offers a user-friendly and extensible API for seamless data manipulation, enabling you to execute common operations such as set, get, delete, and more with ease. The module's design is flexible, accommodating different data storage drivers.\n\n## Key Features\n\n- **Super Lightweight:** MegDB-light is incredibly lightweight, ensuring your applications remain efficient and high-performing. 🚀\n\n- **Type-Safe Operations:** MegDB-light exploits TypeScript’s type system to ensure type safety across your database interactions, enhancing reliability and robustness. 🛡️\n\n- **Extensibility:** MegDB-light is easily extendable. You can implement custom data storage drivers, making the module compatible with a variety of storage solutions. 📚\n\n## Installation\n\nYou can incorporate MegDB-light into your TypeScript project by installing it via npm:\n\n```bash\nnpm install meg.db-light\n```\n\n## How to Use\n\n### MegDB Class\n\nThe `Megdb` class offers a high-level API for data interaction.\n\n```typescript\nimport { Megdb, JSONDriver } from 'meg.db-light';\n\n// Define a type for the data\ninterface User {\n    name: string;\n    age: number;\n    hobbies: string[];\n};\n\ninterface format {\n    \"john\": User;\n};\n\n// Create a new JSONDriver instance\nconst jsonDriver = new JSONDriver\u003cformat\u003e('users.json');\n\n// Create a new Megdb instance with the JSONDriver instance\nconst megDB = new Megdb\u003cformat\u003e(jsonDriver);\n\nasync function main() {\n    // Set a value\n    await megDB.set('john', { name: 'John Doe', age: 30, hobbies: ['reading', 'coding'] });\n\n    // Get a value\n    const john = await megDB.get('john');\n    console.log(john!.name);  // Outputs: John Doe\n\n    // Update a value\n    await megDB.add('john.age', 1);\n\n    // Get the updated value\n    const updatedJohn = await megDB.get('john.age');\n    console.log(updatedJohn);  // Outputs: 31\n\n    // Push a value into an array\n    await megDB.push('john.hobbies', \"gaming\");\n\n    // Get the updated array\n    const updatedHobbies = await megDB.get('john.hobbies');\n    console.log(updatedHobbies);  // Outputs: ['reading', 'coding', 'gaming']\n\n    // Pull a value from an array\n    await megDB.filter('john.hobbies', hobby =\u003e hobby !== 'coding');\n\n    // Get the updated array\n    const finalHobbies = await megDB.get('john.hobbies');\n    console.log(finalHobbies);  // Outputs: ['reading', 'gaming']\n\n    // Delete a value\n    await megDB.delete('john.age');\n\n    // Try to get the deleted value\n    const deletedValue = await megDB.get('john.age');\n    console.log(deletedValue);  // Outputs: undefined\n\n    // Get the type of the 'john.hobbies' property\n    const typeofhobbies = await megDB.typeof('john.hobbies');\n    console.log(typeofhobbies); // Outputs: object\n\n    // Get the type of the 'john.name' property\n    const typeofname = await megDB.typeof('john.name');\n    console.log(typeofname); // Outputs: string\n\n    // Get all data\n    const allData = await megDB.all();\n    console.log(allData);  // Outputs: { john: { name: 'John Doe', hobbies: ['reading', 'gaming'] } }\n};\n\nmain();\n```\n\n### Custom Driver\n\nYou can create your custom driver by extending the `BaseDriver` class and implementing the `loadData` and `saveData` methods.\n\n```typescript\nimport { BaseDriver } from 'meg.db-light';\n\nexport class CustomDriver\u003cT\u003e extends BaseDriver\u003cT\u003e {\n    constructor(filePath: string) {\n        super(filePath);\n    }\n\n    public async loadData(): Promise\u003cT\u003e {\n        // Implement loading data from your custom storage\n    }\n\n    public async saveData(data: T): Promise\u003cvoid\u003e {\n        // Implement saving data to your custom storage\n    }\n}\n```\n\n## Examples\n\n### JSONDriver\n\nA built-in driver for storing data in a JSON file.\n\n```typescript\nimport { Megdb } from 'meg.db-light';\nimport { JSONDriver } from 'megdb/drivers/JSONDriver';\n\n// Define a type for the data\ninterface User {\n    name: string;\n    age: number;\n    hobbies: string[];\n};\n\ninterface format {\n    \"john\": User;\n};\n\n// Create a new JSONDriver instance\nconst jsonDriver = new JSONDriver\u003cformat\u003e('users.json');\n\n// Create a new Megdb instance with the JSONDriver instance\nconst megDB = new Megdb\u003cformat\u003e(jsonDriver);\n\nasync function main() {\n    // Operations with MegDB...\n}\n\nmain();\n```\n\n## License\nThis project is licensed under the GNU General Public License v3.0 License - see the LICENSE file for details.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmegalithofficial%2Fmeg.db-light","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmegalithofficial%2Fmeg.db-light","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmegalithofficial%2Fmeg.db-light/lists"}