{"id":25415284,"url":"https://github.com/zediculz/vanilla-db","last_synced_at":"2025-04-23T19:17:06.884Z","repository":{"id":190761854,"uuid":"683302428","full_name":"zediculz/vanilla-db","owner":"zediculz","description":"VanillaDb is a lightweight browser database library thats built on top of localStorage and sessionStorage.","archived":false,"fork":false,"pushed_at":"2024-02-07T21:53:04.000Z","size":455,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-23T19:16:54.532Z","etag":null,"topics":["broswer","browser-storage","database","javascript","localstorage","sessionstorage"],"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/zediculz.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":"2023-08-26T06:14:17.000Z","updated_at":"2023-12-09T20:59:37.000Z","dependencies_parsed_at":"2023-09-19T00:45:41.723Z","dependency_job_id":"ed4b2809-71dc-4389-8641-8329c6c291c0","html_url":"https://github.com/zediculz/vanilla-db","commit_stats":null,"previous_names":["seyifunmitan/vanilla-db","zediculz/vanilla-db"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zediculz%2Fvanilla-db","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zediculz%2Fvanilla-db/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zediculz%2Fvanilla-db/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zediculz%2Fvanilla-db/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zediculz","download_url":"https://codeload.github.com/zediculz/vanilla-db/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250496990,"owners_count":21440231,"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":["broswer","browser-storage","database","javascript","localstorage","sessionstorage"],"created_at":"2025-02-16T15:34:18.473Z","updated_at":"2025-04-23T19:17:06.842Z","avatar_url":"https://github.com/zediculz.png","language":"JavaScript","readme":"# VanillaDb\n\nVanillaDb is a lightweight browser database library thats built on top of localStorage and sessionStorage.\n\n## Installation\n```bash\n  npm install --save vanilla-db@latest\n```\nOnce the package is installed, you can import the library using import vanillaDb\n\n```javascript\nimport { vanillaDb } from 'vanilla-db'\n```\n\n## Documentation\n### Storing Data \n\nto store data using vanillaDb\n\n```javascript\nconst config = {\n  db: 'local', // or 'session', 'localStorage', 'sessionStorage',\n  key: 'my-database-key' ,\n  data: {\n    name: 'John Doe',\n    age: 40,\n    role: 'React Developer'\n  }\n}\n\nvanillaDb.set(config)\n```\nto Get stored data, call the set() method and pass an object with\nkey: Database key,\ndb:  which can either be \"local || localStorage\" or \"session || sessionStorage\" ,\ndata: the data you are storing (which can be arrays, object, or just a variable or state).\n\n\n\n### Getting Data \nVanillaDb uses key-value pair method in storing datas, you will be able to get the stored data by referencing its database key.\n\n```javascript\nconst query = {\n  db: 'local', // or 'session', 'localStorage', 'sessionStorage',\n  key: 'my-database-key',\n  option: 'all' || 'only'\n}\n\nvanillaDb.get(query)\n```\nto Get stored data, call the get() method and pass an object with\ndb: the database data is stored\nkey: database key.\noption: to either return all the Database or only the data stored.\n\n\n### Sync Data\nsync(copy) allow you to copy or move data within sessionStorage and localStorage, \n\n```javascript\nconst config = {\n  from: 'local', \n  to: 'session',\n  key: 'my-data' ,\n  options: {\n      deleteOld: true // or false,\n      newKey: 'my-synced-data'\n  }\n}\n\nvanillaDb.sync(config)\n```\n\nto use sync(copy) create an object with\n\nfrom: the database you can are copying/syncing data from, \nto: the new database you are copying/syncing to\nkey: the key of the database you want to copy/sync.\n\noptions contains \ndeleteOld: which can either be true or false to delete old stored data\nnewKey: for the new data synced.\n\n## More Features\n- remove(db) - remove the data stored in Database\n- length(db) - return the length of data stored in Database\n- request(db) - fetch data from api (mostly get) and store the data in database for offline usage.\n\n### Usage/Examples\n```javascript\nconst query = {\n  db: 'local' // 'session',\n  key: 'your database key',\n}\n\nvanillaDb.remove(query)\n\n```\nquery contains the database you stored your data and the key of the database you want to remove.\n\n```javascript\nconst db =  'local' // 'session',\n\nvanillaDb.length(db)\n```\ndb is the Database you stored data or the Database you which to know its length.\n\n```javascript\nimport { vanillaDb } from 'vanilla-db'\n\nconst config =  {\n    url: 'api endpoint',\n    db: 'local' // 'session',\n    key: 'database key',\n    options: {'fetch request options'}\n}\n\nvanillaDb.request(config)\n\n```\ndb is the Database you stored data.\n\n\n[![NPM](https://img.shields.io/npm/v/vanilla-db.svg)](https://www.npmjs.com/package/vanilla-db) \n\n[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)\n\n[![Contact](https://img.shields.io/badge/contact-@zediculz-blue.svg?style=flat\u0026logo=twitter)](https://twitter.com/zediculz)\n\n## License\n\nMIT ©","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzediculz%2Fvanilla-db","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzediculz%2Fvanilla-db","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzediculz%2Fvanilla-db/lists"}