{"id":22779560,"url":"https://github.com/isayme/tinydb","last_synced_at":"2025-04-15T14:22:07.854Z","repository":{"id":16485500,"uuid":"19238006","full_name":"isayme/tinydb","owner":"isayme","description":"tiny json file based datebase for small nodejs projects","archived":false,"fork":false,"pushed_at":"2014-05-26T09:12:42.000Z","size":212,"stargazers_count":15,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-25T10:02:29.464Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/isayme.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}},"created_at":"2014-04-28T12:34:50.000Z","updated_at":"2024-06-30T15:37:32.000Z","dependencies_parsed_at":"2022-07-15T23:30:37.309Z","dependency_job_id":null,"html_url":"https://github.com/isayme/tinydb","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/isayme%2Ftinydb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/isayme%2Ftinydb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/isayme%2Ftinydb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/isayme%2Ftinydb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/isayme","download_url":"https://codeload.github.com/isayme/tinydb/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249085642,"owners_count":21210319,"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":[],"created_at":"2024-12-11T20:09:12.758Z","updated_at":"2025-04-15T14:22:07.834Z","avatar_url":"https://github.com/isayme.png","language":"JavaScript","readme":"Purpose\n=======\nTinyDB is a tiny json file based database for NodeJS.   \nNormally, it's better to use it for your little project.\n\nFeatures\n========\n\n- auto save data in memory to local fild after add/delete item;\n- all APIs have a callback function for data handling;\n- name API refering to Mongoose;\n- no third-party dependencies.\n\nUsage\n=====\n```javascript\nvar TinyDB = require('tinydb');\ntest_db = new TinyDB('./test.db');\n\ntest_db.onReady = function() {\n  console.log('database is ready for operating');\n\n  // set info to DB\n  test_db.setInfo('title', 'Test DB', function(err, key, value) {\n    if (err) {\n      console.log(err);\n      return;\n    }\n    \n    console.log('[setInfo] ' + key + ' : ' + value);\n  });\n  \n  // get info from DB\n  test_db.getInfo('title', function(err, key, value) {\n    if (err) {\n      console.log(err);\n      return;\n    }\n    \n    console.log('[getInfo] ' + key + ' : ' + value);\n  });\n  \n  // do other things below\n  test_db.forEach(function (err, item) {\n    if (err) {\n      console.log(err);\n      return;\n    }\n\n    for (var key in item) {\n      console.log(key + ' : ' + item[key]);\n    }\n  });\n}\n```\n\nAPIs\n====\n\n.flush(callback)\n------\nWrite the data in memory to your specified databse file immediately.\n\n.find(query, callback)\n---------\nFind databse items. `query` is a object like `{_id: \"xxxxx\"}`.\n\n.findById(id, callback)\n-----------------------\nFind database item by `id`, equal to `.find({_id: id}, callback)`;\n\n.findByIdAndRemove(id, callback)\n--------------------------------\nFind database item by `id` and remove it from database.\n\n.insertItem(item, idx, callback)\n--------------------------------\nInsert `item` to database. `idx` is optional, default to `0`.\n\n.appendItem(item, callback)\n---------------------------\nAppend `item` to database.\n\nThanks\n===========\nSource code of function `._guid()` is refering to [How to create a GUID / UUID in Javascript?](http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript).\n\nContact\n=======\n`mail` : [isaymeorg@gmail.com](mailto:isaymeorg@gmail.com)","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fisayme%2Ftinydb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fisayme%2Ftinydb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fisayme%2Ftinydb/lists"}