{"_id":"@ar-maged/nedb-promises","_rev":"1-ad3c352771dd5c458412ea88c2d7477f","name":"@ar-maged/nedb-promises","dist-tags":{"latest":"4.1.0"},"versions":{"4.1.0":{"name":"@ar-maged/nedb-promises","version":"4.1.0","description":"A dead-simple promise wrapper for nedb.","main":"index.js","scripts":{"docs":"jsdoc2md ./src/*.js > docs.md --no-gfm","test":"mocha --reporter spec --timeout 10000"},"repository":{"type":"git","url":"git+https://github.com/bajankristof/nedb-promises.git"},"keywords":["nedb","promises","promise"],"author":{"name":"Kristóf Baján"},"license":"ISC","bugs":{"url":"https://github.com/bajankristof/nedb-promises/issues"},"homepage":"https://github.com/bajankristof/nedb-promises#readme","dependencies":{"@ar-maged/nedb":"^2.0.0"},"devDependencies":{"chai":"^4.2.0","jsdoc-to-markdown":"^5.0.3","minimist":"^1.2.5","mocha":"^6.2.3"},"gitHead":"30ef116d40312dc22daf7637431ff6edf0418f0a","_id":"@ar-maged/nedb-promises@4.1.0","_nodeVersion":"12.18.2","_npmVersion":"6.14.7","dist":{"integrity":"sha512-qAfacINfT2FlhWSZFnKJoH6kEab9jvNycJ2acmWx2MBeKg2+SUQgQV+8T3UHE5FdcGkEZP/Xb5naw0hbBV71Dg==","shasum":"38a9c3b5f154e26ca631e1e4661bb277781a410b","tarball":"https://registry.npmjs.org/@ar-maged/nedb-promises/-/nedb-promises-4.1.0.tgz","fileCount":18,"unpackedSize":54373,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJffXnwCRA9TVsSAnZWagAAcDoP+QFqb5epTZMzz3UQDX+q\npyhizn9DpfxZOHO7+kjTJBu6hkiONA+DtXGdbxpuLsafVC0+D1dSovsYHisy\nW0qlAMlf7Uz+Wr5+CZDTBEDEbRvCAEKuYZ1XExVyhh9k8Fo0vzYb5aIXAOfV\nh8dFchpIxyX19ik8okiDyC31vquDT1YxhchBRFSuEED6p7o3me5Qun/0rwpR\nRHriAtxo2Vjs+XEbq4/66RhbIVTAIAEjGPgGnr1yfDwNYM5jUDYwjWtJ0sZW\ncd0DTAaIuV1lDNFHAPGrJwpR2xL/zfT+8iEk8ffWoY913kIKgJfEA6QYXKY2\nZkC6uT7z4z0pRhoeuPUQi5R0o8NbBu858d65IVt8Ol3rcSeviYTnvviboTnu\nRwOq8T/ZLa7wVuv9MYBJAGKjOlzzXSD6j/Kb6vA4K7ceqfgrtYDW4w6GTJYe\nBZgHRo6VRMzOP5Tpd1Yalib5RIVh+NjbG2NWFt5ZZ/yaEacVVx0u5Xt3Fns2\neMkMTmsSNetKgyMLETF4blqY7tQ4+QhshcCuaUy5bznLnTFOlL5fSOClAq0l\nEgAX6Q1JytHgM+5HEP/zP4il5bly/Jby4Kq6ydUGMKtoNBJ0clul4meyqsqA\n2S1/9sFZ+Ykv5uTZSHrFhrLMBJTQ9QyvKj7pEG62Ix/GPOe8maNPv5j4TBJN\nemfE\r\n=aI9S\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDepBnwAap96aQKmRzcOibrJtqfSDEqpnzQ5r6jJyYpXAiEAh/vWhLwLJv8PTANpNPrE02gdbIGQbiwhkYwS1D+wT+M="}]},"maintainers":[{"name":"ar-maged","email":"abdelrahman@maged.rocks"}],"_npmUser":{"name":"ar-maged","email":"abdelrahman@maged.rocks"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/nedb-promises_4.1.0_1602058735785_0.4389004464660742"},"_hasShrinkwrap":false}},"time":{"created":"2020-10-07T08:18:55.738Z","4.1.0":"2020-10-07T08:18:55.928Z","modified":"2022-04-04T15:14:13.243Z"},"maintainers":[{"name":"ar-maged","email":"abdelrahman@maged.rocks"}],"description":"A dead-simple promise wrapper for nedb.","homepage":"https://github.com/bajankristof/nedb-promises#readme","keywords":["nedb","promises","promise"],"repository":{"type":"git","url":"git+https://github.com/bajankristof/nedb-promises.git"},"author":{"name":"Kristóf Baján"},"bugs":{"url":"https://github.com/bajankristof/nedb-promises/issues"},"license":"ISC","readme":"## `@ar-maged/nedb-promises`\n\nUtilizes the `@ar-maged/nedb` package.\n\n---\n\n![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```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 four major exceptions. \n* There are no callbacks.\n* `loadDatabase` has been renamed to `load`.\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(() => {\n    return datastore.find(...)\n  })\n  .then(\n    // use the retrieved documents\n  )\n\n;(async () => {\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","readmeFilename":"README.md"}