{"id":15908080,"url":"https://github.com/spiffgreen/browsedb","last_synced_at":"2025-03-17T23:32:07.632Z","repository":{"id":50143315,"uuid":"372659587","full_name":"SpiffGreen/browsedb","owner":"SpiffGreen","description":"BrowseDB is a javascript clientside library for managing localStorage data in mongoose style.","archived":false,"fork":false,"pushed_at":"2021-06-09T01:46:53.000Z","size":76,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-19T07:28:15.248Z","etag":null,"topics":["browsedb","browser","clientside","data","databases","db","frontend","javascript","localstorage"],"latest_commit_sha":null,"homepage":"https://spiffgreen.github.io/browsedb-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/SpiffGreen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-06-01T00:29:38.000Z","updated_at":"2021-08-18T13:55:50.000Z","dependencies_parsed_at":"2022-08-25T20:11:28.713Z","dependency_job_id":null,"html_url":"https://github.com/SpiffGreen/browsedb","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpiffGreen%2Fbrowsedb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpiffGreen%2Fbrowsedb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpiffGreen%2Fbrowsedb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpiffGreen%2Fbrowsedb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SpiffGreen","download_url":"https://codeload.github.com/SpiffGreen/browsedb/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221703403,"owners_count":16866534,"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":["browsedb","browser","clientside","data","databases","db","frontend","javascript","localstorage"],"created_at":"2024-10-06T14:09:30.554Z","updated_at":"2024-10-27T16:17:55.463Z","avatar_url":"https://github.com/SpiffGreen.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\u003cdiv align=\"center\"\u003e\n\u003ch1\u003eBrowseDB 🛢️\u003c/h1\u003e\n\nBrowseDB is a JavaScript clientside library for managing localStorage data in mongoose style. BrowseDB provides its users, methods for managing localStorage data efficiently. It can be used for simple CRUD operations. BrowseDB's data is stored in string format but all data operations are done in JSON format.\n\n![](https://img.shields.io/github/license/SpiffGreen/browsedb) ![](https://img.shields.io/npm/v/browsedb) ![](https://img.shields.io/github/size/spiffgreen/browsedb/browsedb.js)\n\n![](https://img.shields.io/github/languages/top/spiffgreen/browsedb) ![](https://img.shields.io/github/forks/SpiffGreen/browsedb) ![](https://img.shields.io/github/issues/SpiffGreen/browsedb) ![](https://img.shields.io/github/issues/SpiffGreen/browsedb)\n\n\n[Visit Site For more Docs](https://spiffgreen.github.io/browsedb-js/)\n\u003c/div\u003e\n\n\u003c!-- ![](https://raw.githubusercontent.com/SpiffGreen/browsedb/main/public/screenshot.PNG) --\u003e\n\n## 📕 Terminologies\n`Collections` - All BrowseDB instances are called collections, as they are just collections(arrays) of objects(documents).\n\n`Documents` - As you might have guessed, are simply objects.\n\n`Schema` - A schema is simply an object that describes the expected structure or blueprint of documents of a particular collection. This could be used for some sort of type checking. It is optional.\n\n## ⚙️Usage and Settings\nFirst, to use browsedb. Include/import browsedb, then create an instance of browsedb. Example\n```javascript\n    import BrowseDB from \"browsedb\";\n\n    const schema = {\n        text: {\n            type: String,\n            required: true\n        },\n        done: Boolean,\n        date: {\n            type: Number,\n            required: true,\n            default: Date.now\n        }\n    };\n    const todos = new BrowseDB(\"todos\", schema);\n```\n\n## ▶️Methods\n* `create` - Used for creating documents. It accepts an object containing required data for object creation and returns a copy of the new document inserted into localStorage with its ID. BrowseDB generates a unique ID for the newly inserted document.\n```javascript\n    todos.create({ text: \"Learn BrowseDB\", done: false });\n```\n\n* `find` - For finding documents. It accepts two optional parameters: __query__ and __key__. __query__ is used in similar fashion to 'WHERE' in SQL like databases, While __key__ is used for filtering results. Example\n```javascript\n    todos.find(); // Returns all documents\n    todos.find({}) // Returns all documents\n    todos.find({ done: true }); // Returns all documents where done equal true\n    todos.find({ done: false }, {done: 0, id: 0}); // Returns documents where done equal false but doesn't show done and id's of each document.\n```\n\n* `findById` - For finding documents based on id. It accepts one parameter: __id__. __id__(string) represents id of a document. It returns a document with the passed id.\n```javascript\n    todos.findById(\"zUVxUed827\"); // Returns Document with id 'zUVxUed827'\n```\n\n* `update` - For updating data in document(s). It accepts two parameters: __query__ and __data__. Here, query is used as 'WHERE' would be used Relational databases, while __data__ represents the new data to be put into selected documents. The below example will find all documents where done = false, and update the text field.\n```javascript\n    todos.update({done: false}, {text: \"Todo is not yet done\"});\n```\n\n* `updateById` - For updating data in a document based on id. It finds a document by id, updates its content and returns the updated content. It accepts two parameters: __id__ and __data__.\n\n* `updateAll` - For updating all documents data at once. It accepts one parameter: __data__.\n\n* `delete` - Finds and deletes documents. Accepts one parameter: __query__ - Where the delete operation should take place.\n\n* `deleteById` - Finds, deletes and returns a document with id passed to it. Accepts one parameter __id__.\n\n* `deleteAll` - Deletes all documents in a collection.\n\n* `remove`  - This function is a bit similar in behaviour to `delete`.\n\n## Installation\n### Content Delivery Networks\n🚀CDN Link   https://unpkg.com/browsedb@1.1.2/browsedb.min.js\n\nHTML Tag\n```html\n    \u003cscript src=\"https://unpkg.com/browsedb@1.1.2/browsedb.min.js\"\u003e\u003cscript\u003e\n```\n\n### 📦Using NPM\n```bash\n    npm install browsedb\n```\n\n## Caveats\n### Schema\nLike mongoose, BrowseDB supports schema. But in BrowseDB uses the builtin types available to javascript for type checking. Hence, `Date` isn't a type as it produces a number.\n\nBut there is a work around for this. Instead of:\n```javascript\n    {\n        detail: {\n            type: String,\n            required: true\n        },\n        date: {\n            type: Date,\n            default: Date.now\n        }\n    }\n```\nOne should do:\n```javascript\n    {\n        detail: {\n            type: String,\n            required: true\n        },\n        date: {\n            type: Number,\n            default: Date.now\n        }\n    }\n```\n\n## ⛏️Development\n*   yarn build or npm run build - produces a production version of library under the lib folder\n\n## ⭐️Show your support\nPlease star this repository if this project helped you!\n\n## 👋 Contributing\nPlease read the [CONTRIBUTING.md](./CONTRIBUTING.md) file to see how to contribute.\n\n## 🌤️Browser compatibility\nBrowsedb works across all browsers that support localStorage.\nYou could check for compatibility here:\n*   https://caniuse.com/#search=localStorage\n\n## 📄License\n[GPL-3.0 License](./LICENSE)\n\nCopyright (c) Spiff Jekey-Green\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspiffgreen%2Fbrowsedb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspiffgreen%2Fbrowsedb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspiffgreen%2Fbrowsedb/lists"}