{"_id":"@casoetan/nj-db","_rev":"2-2f789e334126f1a31cf1b7fb7b54eabe","name":"@casoetan/nj-db","dist-tags":{"latest":"0.0.2"},"versions":{"0.0.1":{"name":"@casoetan/nj-db","version":"0.0.1","description":"A simple interface for saving and retrieving data to and from a database","main":"./lib/cjs/index.js","module":"./lib/esm/index.js","types":"./lib/esm/index.d.ts","scripts":{"test":"env TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\" }' mocha -r ts-node/register ./test/**/*.ts --reporter spec --inline-diffs","tsc":"tsc -p tsconfig.json && tsc -p tsconfig-cjs.json","prepublish":"npm run tsc"},"repository":{"type":"git","url":"git+github.com/casoetan/nj-db.git"},"keywords":["database","nice"],"author":{"name":"Deji Soetan"},"license":"MIT","bugs":{"url":"https://github.com/casoetan/nj-db/issues"},"homepage":"https://github.com/casoetan/nj-db#readme","dependencies":{"@google-cloud/firestore":"^4.12.0"},"devDependencies":{"@types/chai":"^4.2.18","@types/mocha":"^8.2.2","chai":"^4.3.4","mocha":"^8.4.0","ts-node":"^10.0.0","typescript":"^4.2.4"},"_id":"@casoetan/nj-db@0.0.1","_nodeVersion":"14.17.0","_npmVersion":"6.14.13","dist":{"integrity":"sha512-47jtuNcNC3gf+u1xNJ8fqi86LgsJwyufY23T3OX4WprLA70dej3t/XaNFgC7PQSN/FCK+aCXN9AWb4F6n9ZmTQ==","shasum":"baf3d963a30f1df0203ad46ddd5011c3691e15c9","tarball":"https://registry.npmjs.org/@casoetan/nj-db/-/nj-db-0.0.1.tgz","fileCount":22,"unpackedSize":29651,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgrkMCCRA9TVsSAnZWagAA4KAP/joCgYyTX2u9+hJ8huId\nh9TzMf369x4QqGoaZiVyi8WoUPBb8kzxNgDy2osl4qZ8btVrSY1qi7tyY5Np\nitHEiiyfwFbRP/kdRjxjqNukDpRwGQ+oF5DCc6kW26hSm3fRO7fHMWCuBLju\nib0KIwnSHxbiOBuOUZndpXGNBrutCfYi8tpQYZCTer7VTpTjzvH7MtR/Wnzl\n00uKHnmgmuMQPQNjwkLizbysyPrf3pogg6Qr1msgda2fv5Z831a0Ri6TWEwM\nPsonyaMtwIw/443yrOJaCXYrCohJqa3IoLuZEbP34O3Ya33UV+LfJZAMnOpa\nZtsxVEH2z1Fg28HHpGwyxNlLHLhKYhNTluM707FtZIVGQrA0iiuu9+BE36pP\nEFsTkZ94QHccDP3aiapBBC8ia1dBOiVcAA1WbEyn3/kRsWYDKVpvP2ZJtlIE\nHziZKBjSfDfLxMkNkQWcutwhtVGNaNjQfymKwzOuo2gfc8WdJhEqh6eKyI6C\n1RbWbEQLPTBimYYrCT8KEJgA1xVJYqHdQNd0W5Q3/BYOt4vLp74ovc+oPFyJ\nhtNHdfF6yh2KkNsTo+ArRooE5YSBnWYC7e9JiQxtiIBdHVUDp5F9FZMzdOjr\nf/0N6/fFqjDlcYSYu4S2OqtymUaqj91BIDe4/a5w/1PMbbpRBSBhMuC3SiJj\nyHOS\r\n=mMT5\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFILP4TuPzQLwsadGJ+Mxm8uIek0+ZEsM92bCmSc39/oAiEA//5Zr3Yoq9sl3vrLec4PuZbV9+7No2GLqNV2U6wQdXA="}]},"_npmUser":{"name":"deji5","email":"casoetan@gmail.com"},"directories":{},"maintainers":[{"name":"deji5","email":"casoetan@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/nj-db_0.0.1_1622033153775_0.010093575077472217"},"_hasShrinkwrap":false},"0.0.2":{"name":"@casoetan/nj-db","version":"0.0.2","description":"A simple interface for saving and retrieving data to and from a database","main":"./lib/cjs/index.js","module":"./lib/esm/index.js","types":"./lib/esm/index.d.ts","scripts":{"test":"env TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\" }' mocha -r ts-node/register ./test/**/*.ts --reporter spec --inline-diffs","tsc":"tsc -p tsconfig.json && tsc -p tsconfig-cjs.json","prepublish":"npm run tsc"},"repository":{"type":"git","url":"git+github.com/casoetan/nj-db.git"},"keywords":["database","nice"],"author":{"name":"Deji Soetan"},"license":"MIT","bugs":{"url":"https://github.com/casoetan/nj-db/issues"},"homepage":"https://github.com/casoetan/nj-db#readme","dependencies":{"@google-cloud/firestore":"^4.12.0"},"devDependencies":{"@types/chai":"^4.2.18","@types/mocha":"^8.2.2","chai":"^4.3.4","mocha":"^8.4.0","ts-node":"^10.0.0","typescript":"^4.2.4"},"_id":"@casoetan/nj-db@0.0.2","_nodeVersion":"14.17.0","_npmVersion":"6.14.13","dist":{"integrity":"sha512-ckXMCBf/7Bn5LUYpT5uei2Dhdj4/5+m8osnkCCO2Daxy1MhL0WA1i8iTQTbiGeqcrsFFhaEa9U0DjFMzn0jYBQ==","shasum":"04c93755916c5b435ef3b6fba0d7fc7760e7da2b","tarball":"https://registry.npmjs.org/@casoetan/nj-db/-/nj-db-0.0.2.tgz","fileCount":22,"unpackedSize":30651,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJgr5bgCRA9TVsSAnZWagAAk8UP/2i42OTdbYkOUbYjU5qo\nYxOkFK63KiVxaBZHjJhUsU7GQqgXWHnc1cIGjY0GGinOm02Gsn3fS6o8Mo9M\n+yrs+Kg4WAQfSg+F/XXGMpew/RamrZnYudLieiv6XAPUcEiMdis/WITg+aKE\nb3XwfIEmdpFA6mxNF55nFUdKRflEgK1DCfYc9RPV4dV7x1I9tVg+5l9JYHXn\nsVD3XQ+KRMSsmWhP6uxLw3pjnFS/iZFo4cBWSj6ZKCJ6HVT+GitD+8nQarbm\n75qoXr8ryNunu+L+o4vYK5qMeu4F2hpS6vA7gnaFZzJ/k1B0ESzJ2x+ksGLU\nF9GnGqAXIyS33qdKgd6iVYKp4o/UPeqhSSrwbhpABfEyzhqktTp+PLd+sAKC\nlAATgGXJouu2+SnzRL8NWpVKW5Cvt2MzGlh/wnpx6EWxbNSySZtvmszWCY6B\nfo3wodOEqHrpXigpK5LKaGTB9pJJQc6LjVQ9cXAmmlVb6mGjUj4vjDSgFBMY\nMmkYmttofLnudTCue4tRD/QmpPpmUhBbjTd0g4xkUJK5wB0d164MqHhHVsXO\nQQsFeka34T7SdUIzZz6tQLSQUAqriY2FU3FIxF9LQQ1bgyDZXNrAS5SncIfn\nvIg54BaTOFaYXPyU2G1/vlcYLrfroDgcDo+0MWq3EMr9wCkGW51x0Ty9ArJR\nSfje\r\n=hatR\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIE44jFLuTGzKuT9jh5vZ99P11+2pXOqg2yT7QztN/kf0AiBVsTdxPlLxRr+FNGgCsrgG67wRbYG3TWIk22+wTbscKg=="}]},"_npmUser":{"name":"deji5","email":"casoetan@gmail.com"},"directories":{},"maintainers":[{"name":"deji5","email":"casoetan@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/nj-db_0.0.2_1622120160233_0.7775111130196093"},"_hasShrinkwrap":false}},"time":{"created":"2021-05-26T12:45:53.422Z","0.0.1":"2021-05-26T12:45:53.915Z","modified":"2022-04-04T22:02:44.810Z","0.0.2":"2021-05-27T12:56:00.434Z"},"maintainers":[{"name":"deji5","email":"casoetan@gmail.com"}],"description":"A simple interface for saving and retrieving data to and from a database","homepage":"https://github.com/casoetan/nj-db#readme","keywords":["database","nice"],"repository":{"type":"git","url":"git+github.com/casoetan/nj-db.git"},"author":{"name":"Deji Soetan"},"bugs":{"url":"https://github.com/casoetan/nj-db/issues"},"license":"MIT","readme":"# [nj-db](https://www.npmjs.com/package/@casoetan/nj-db) \n\nThis NPM package provides a simple interface for saving and retrieving data to and from a database.\n\nThere's nothing more core to a web application than reading from and writing to its database. This package provides methods to enable just that: reading from a database, and writing to a database.\n\n## NPM package\nIn particular, this package reads from and writes to a [GCP Firestore](https://cloud.google.com/firestore/docs) database.\n\nBut it also does a bit more. When writing data, the package saves that data to an in-memory cache. When retrieving data, it first checks its in-memory cache for matching data. If a match for the query is found, and if the match is sufficiently fresh, it will return that data without querying Firestore.\n\nThe size of the cache is limited. The package will have to make sure that the size of the cache – in bytes – never eclipses its allocation.\n\n## Usage\n- Create application in GCP\n- Download config file\n- Add path to the GCP config file to env. Use the keyword: GOOGLE_APPLICATION_CREDENTIALS\n\nAn example environment is in `.env.sample`\n\n## Examples of using this library\n\n### Retrieve an entry from a firestore collection (users)\n```js\n    const db = new Database({ project_id: process.env.GCP_PROJECT_ID });\n    // Read an entry from a db\n    const result = await db.readOne({ collection: 'users', id: '1234' });\n    return res.send(result);\n```\n\n### List all values from a firestore collection (users)\n```js\n    const db = new Database({ project_id: process.env.GCP_PROJECT_ID });\n    // This also allows filtering\n    const result = await db.readMany({ collection: 'users' });\n    return res.send(result);\n```\n\n### Create an entry in a firestore collection (users)\n```js\n    const db = new Database({ project_id: process.env.GCP_PROJECT_ID });\n    const id = uuid4()\n    db.write({ collection: 'users', id }, body: {name: 'Dji'});\n    res.statusCode = 201\n    return res.end();\n```\n\n## TODO\n* Pagination of entries\n* Database memory management\n* Filters other than equal\n","readmeFilename":"README.md"}