{"id":51114068,"url":"https://github.com/asheghi/fson-db","last_synced_at":"2026-07-09T01:30:23.644Z","repository":{"id":47745521,"uuid":"395778324","full_name":"asheghi/fson-db","owner":"asheghi","description":"Data Persistence for DUMMIES","archived":false,"fork":false,"pushed_at":"2022-05-10T12:13:23.000Z","size":41,"stargazers_count":13,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-06-24T20:21:26.756Z","etag":null,"topics":["config","database","db","javascript","json","nodejs"],"latest_commit_sha":null,"homepage":"https://npmjs.com/package/fson-db","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/asheghi.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}},"created_at":"2021-08-13T19:55:03.000Z","updated_at":"2024-01-29T01:39:01.000Z","dependencies_parsed_at":"2022-07-22T00:46:58.590Z","dependency_job_id":null,"html_url":"https://github.com/asheghi/fson-db","commit_stats":null,"previous_names":["semycolon/fson-db","semycolon/fson"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/asheghi/fson-db","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asheghi%2Ffson-db","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asheghi%2Ffson-db/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asheghi%2Ffson-db/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asheghi%2Ffson-db/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/asheghi","download_url":"https://codeload.github.com/asheghi/fson-db/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/asheghi%2Ffson-db/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35283905,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-08T02:00:06.796Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["config","database","db","javascript","json","nodejs"],"created_at":"2026-06-24T20:01:54.822Z","updated_at":"2026-07-09T01:30:23.639Z","avatar_url":"https://github.com/asheghi.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Data Persistence for **DUMMIES**\n\nit gives you a magical javascript object that persists changes even after restart, and you can watch for changes too!\n\nboth Node.js and Browser environment are supported.\n\n### Quick Guide:\n\n```javascript\n//get the magical object\nimport Fson from 'fson-db';\nconst starwars = Fson('./file/path');\n\n// save data\nstarwars.owner = 'Disney';\nstarwars.movies = [\n  {\n    title: 'A New Home',\n    date: new Date(1997, 5, 25),\n    directory: {\n      name: 'George Locas',\n    }\n  },\n  {\n    title: 'The Force Awakens',\n    date: new Date(2015, 12, 18),\n    directory: {\n      name: 'J.J. Abraham',\n    }\n  },\n]\n//read data just like regular js object\nconst filtered = starwars.movies.filter(it =\u003e it.date.getUTCFullYear() \u003e 2012);\nconsole.log(`${filtered.length} movies since ${starwars.owner}`)\n\n//watch for changes\nimport {watch} from 'fson-db';\nwatch(starwars,(field,newValue,oldValue) =\u003e {\n  if (field === 'owner') {\n    console.log(`${newValue} is the new boss here!`)\n  }\n  if (field === 'movies') {\n    console.log(`a new movie has been released!`)\n  }\n})\n```\n\n---\n\n#\n\n### How does it work?\n`fson-db` load object from **DataStorage**, keep a copy of object in memory and apply effects to DataStorage.\n\n**DataStorage** saves data with `JSON` format in `LocalStorage` for Browsers and `FileSystem` for Node.JS.\n\n\n#\n\nthe following apis are supported, full js object apis support is in progress.\n\nFull Example:\n\n```javascript\n//browser\nimport Fson from 'fson-db';\n\n//Node.js\nconst Fson = require('fson-db');\n\n//specify a directory path\nconst dbPath = './config';\n\n//db is a js object! but any changes to in will be persistent!\n//dbPath is only required for Node.js\nconst db = Fson(dbPath); //db must be a constant!\n\n//save any type of literals\ndb.name = 'john doe';\ndb.age = 24;\ndb.pi = 3.1415;\ndb.isActive = true;\ndb.date = new Date();\n\n//fetch literals\nconsole.log(db.name) // john doe\nconsole.log(db.age) //  24\nconsole.log(db.pi) //  3.1415\nconsole.log(db.isActive) //  true\nconsole.log(db.date) //  \"1997-02-19T20:30:00.000Z\"\n\n\n//save objects!\ndb.object = {\n  foo: 'bar',\n}\n\n//fetch objest and nested fields\nconsole.log(db.object); // { foo:\"bar\" }\nconsole.log(db.object.foo); // bar\n\n//modify nested objects\ndb.object.foo = 'rab';\nconsole.log(db.object.foo); // rab\n\n\n//save arrays!\ndb.numbers = [1, 2, 3, 4, 5, 6];\n\n//modify arrays!\ndb.numbers = db.numbers.filter(i =\u003e i % 2 == 0);\nconsole.log(db.numbers); // [ 2, 4, 6 ]\n\n//push to arrays\ndb.numbers.push(8, 10, 12);\nconsole.log(db.numbers); // [ 2, 4, 6, 8, 9, 10 ]\n\n//save array of objects\ndb.users = [{id: 1}, {id: 2}]\nconsole.log(db.users[0].id); // 1\nconsole.log(db.users.length); // 2\n\n//modify with indexes!\ndb.users[1] = {id: 3}\nconsole.log(db.users[1].id); // 3\n```\n\nLoop through entries\n\n```javascript\n//list entries with Object.keys\ndb.obj = {\n  one: 'the_one',\n  two: 'the_two',\n  three: 'the_three',\n};\nconsole.log(Object.keys(db.obj)) // ['one', 'two', 'three']\n\n//loop through object keys\nfor (const key in db.obj) {\n  const value = db.obj[key];\n  console.log(`${key}: ${value}`);\n}\n\nfor (const [key, value] of Object.entries(db.obj)) {\n  console.log(`${key}: ${value}`);\n}\n\n\n//the above example also works for nested objects\n```\n\nDelete Operator\n\n```javascript\ndb.obj = {};\ndelete db.obj;\nconsole.log(typeof db.obj) // 'undefined'\n\n//nested objects!\ndb.obj = {\n  nested: {},\n};\ndelete db.obj.nested;\nconsole.log(typeof db.obj.nested) // 'undefined'\n```\n\nNote: high performance is not a priority for now, everything is synchronous, so use `db` inside `async` functions\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasheghi%2Ffson-db","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fasheghi%2Ffson-db","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fasheghi%2Ffson-db/lists"}