{"id":13593773,"url":"https://github.com/bajankristof/nedb-promises","last_synced_at":"2025-05-16T13:04:27.784Z","repository":{"id":21475556,"uuid":"92910450","full_name":"bajankristof/nedb-promises","owner":"bajankristof","description":"A dead-simple promise wrapper for nedb.","archived":false,"fork":false,"pushed_at":"2024-08-25T00:30:24.000Z","size":492,"stargazers_count":299,"open_issues_count":1,"forks_count":45,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-10-29T15:29:30.619Z","etag":null,"topics":["callback","cursor","database","nedb","nedb-promises","promise","promise-wrapper"],"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/bajankristof.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","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":"2017-05-31T06:04:29.000Z","updated_at":"2024-10-07T02:29:52.000Z","dependencies_parsed_at":"2024-06-09T03:42:28.524Z","dependency_job_id":"b036a819-5a81-42af-b6cc-e96cd82d517f","html_url":"https://github.com/bajankristof/nedb-promises","commit_stats":{"total_commits":104,"total_committers":12,"mean_commits":8.666666666666666,"dds":"0.17307692307692313","last_synced_commit":"594717c8a20e654f1e0af5c4e9aabc9f194c8038"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bajankristof%2Fnedb-promises","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bajankristof%2Fnedb-promises/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bajankristof%2Fnedb-promises/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bajankristof%2Fnedb-promises/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bajankristof","download_url":"https://codeload.github.com/bajankristof/nedb-promises/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245435817,"owners_count":20614979,"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":["callback","cursor","database","nedb","nedb-promises","promise","promise-wrapper"],"created_at":"2024-08-01T16:01:24.363Z","updated_at":"2025-03-26T09:08:31.788Z","avatar_url":"https://github.com/bajankristof.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"![nedb-promises](https://github.com/bajankristof/nedb-promises/blob/master/logo.svg \"nedb-promises\")\n\nA dead-simple promise wrapper for [nedb](https://github.com/louischatriot/nedb#readme).\n\nCheck out the [docs](https://github.com/bajankristof/nedb-promises/blob/master/docs.md).\n\n##### IMPORTANT\n**As of `nedb-promises` `5.0.0` [nedb](https://github.com/louischatriot/nedb#readme) package has been replaced with a fork of the original package, [@seald-io/nedb](https://github.com/seald/nedb) to solve some vulnerability issues originating from `nedb`!**\n\n```js\nconst Datastore = require('nedb-promises')\nlet datastore = Datastore.create('/path/to/db.db')\n\n// #1\ndatastore.find({ field: true })\n  .then(...)\n  .catch(...)\n  \n// #2\ndatastore.find({ field: true })\n  .exec(...)\n  .then(...)\n  .catch(...)\n\n// #1 and #2 are equivalent\n\ndatastore.findOne({ field: true })\n  .then(...)\n  .catch(...)\n  \ndatastore.insert({ doc: 'yourdoc' })\n  .then(...)\n  .catch(...)\n  \n// or in an async function\nasync function findSorted(page, perPage = 10) {\n  return await datastore.find(...)\n      .sort(...)\n        .limit(perPage)\n        .skip(page * perPage)\n}\n```\n\n### Installation\n```sh\nnpm install --save nedb-promises\n```\n\n### Usage\nEverything works as the original module, with a couple of exceptions:\n* There are no callbacks.\n* `loadDatabase` has been renamed to [`load`](https://github.com/bajankristof/nedb-promises/blob/master/docs.md#Datastore+load).\n* The cursor's `projection` method has been renamed to [`project`](https://github.com/bajankristof/nedb-promises/blob/master/docs.md#Cursor+project).\n* You should call `Datastore.create(...)` instead of `new Datastore(...)`. This way you can access the original [nedb](https://github.com/louischatriot/nedb#readme) properties, such as `datastore.persistence`.\n* As of v2.0.0 the module supports events 😎... Check out the [docs about events](https://github.com/bajankristof/nedb-promises/blob/master/docs.md#Datastore)!\n\nCheck out the [original docs](https://github.com/louischatriot/nedb#readme)!\n\n#### load( )\nYou don't need to call this as the module will automatically detect if the datastore has been loaded or not upon calling any other method. \n```js\nconst Datastore = require('nedb-promises')\nlet datastore = Datastore.create('/path/to/db.db')\ndatastore.load(...)\n  .then(...)\n  .catch(...)\n```\n\n#### find( [query], [projection] ), findOne( [query], [projection] ), count( [query] )\nThese methods will return a Cursor object that works the same way it did before except when you call \"exec\" it takes no arguments and returns a Promise.\nThe cool thing about this implementation of the Cursor is that it behaves like a Promise. Meaning that you can `await` it and you can call `.then()` on it.\n\n```js\nconst Datastore = require('nedb-promises')\nlet datastore = Datastore.create('/path/to/db.db')\n\n//outside Promise chain\ndatastore.find(...)\n  .then(...)\n  .catch(...)\n  \n//insinde Promise chain\ndatastore.insert(...)\n  .then(() =\u003e {\n    return datastore.find(...)\n  })\n  .then(\n    // use the retrieved documents\n  )\n\n;(async () =\u003e {\n  await datastore.find(...).sort(...).limit()\n})()\n```\n\n#### other( ... )\nAll the other methods will take the same arguments as they did before (except the callback) and will return a Promise.\n\nCheck out the [docs](https://github.com/bajankristof/nedb-promises/blob/master/docs.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbajankristof%2Fnedb-promises","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbajankristof%2Fnedb-promises","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbajankristof%2Fnedb-promises/lists"}