{"_id":"@bonjourjohn/fixture-manager","_rev":"2-6df8b176fb62c18b4dc1fff837a049ee","name":"@bonjourjohn/fixture-manager","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"@bonjourjohn/fixture-manager","version":"1.0.0","description":"Simple class allowing to manage fixture easily","main":"index.js","directories":{"test":"test"},"scripts":{"test":"mocha -b"},"repository":{"type":"git","url":"git+https://github.com/nicolasespiau/fixture-manager.git"},"keywords":["fixtures","mongodb","tests"],"author":{"name":"ESPIAU Nicolas"},"license":"ISC","bugs":{"url":"https://github.com/nicolasespiau/fixture-manager/issues"},"homepage":"https://github.com/nicolasespiau/fixture-manager#readme","devDependencies":{"mocha":"^5.2.0","mongodb":"^3.1.1","unit.js":"^2.0.0"},"gitHead":"6bd2d0a7e529f286cf3174bf45a3d42849a15aba","_id":"@bonjourjohn/fixture-manager@1.0.0","_npmVersion":"5.6.0","_nodeVersion":"9.9.0","_npmUser":{"name":"bonjourjohn","email":"nicolas.espiau@gmail.com"},"dist":{"integrity":"sha512-bFslE0G2OdtoLYoozGdddmhA4q4ZEnZal9QmxPGE7UHgDiA0wGT3STQbsNaU4OGVAxCUPKQL7gk3ClCgxAX57Q==","shasum":"45f83958e4f5bdf6316b3d8a87ff255d44f81812","tarball":"https://registry.npmjs.org/@bonjourjohn/fixture-manager/-/fixture-manager-1.0.0.tgz","fileCount":6,"unpackedSize":15035,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbYDNnCRA9TVsSAnZWagAAyx4P/3FdsthfZMqzwLr/Ipns\n8CT9w+0hXQxdsvPUB6GOlMVomvy05MH/AGZtnp+Vd508S6XWeNQWPWH8L5Gj\n1vjufevA9e50Pcjq+w2rfmODfpz6+/k08/IBfaG1nqhzvY6Um8smyEoPELLw\nucPZ7nYbwuXpNQCJW97N0Jm7O2MzuBl82HFod+LTBZjDt4qDpsi+XA7k885o\n7Lpp7GmKKZRqohGmULFZyPcOdMjLFh5WQAi3BBJTjkaBff5ADcIgbWu0DJnK\nOmyX59uhkhlN7nMWUIo7JXi3nDXKR3wbphpCVeHgQuK2U7Ql5FVPsOFYiM4n\npDAbdFJPPBeULApkkWGeohSv+AzpWHLlmGrxGg9h5G8Z51eAZRO/2UF57B7y\n9+IlPHus8rfIYBPaG2g6GRJj6F5iovWN3Rz0/Im8/a+6lMRMn8qUxkoNYvdb\nIgPn50cb5I3HX1k5VXkeWee7enY9sthAgzsUudd81btrU7CgPJ659jtIiDKm\nM6bi8KZvjKGxpb/e1Q8dbIg6V+QLowsjm3twDTY2hVUg5aK7lf+ADbxulAmg\n+TgcVrfCqivvi2hn+N2weYAjjHjruY3gx49Qt7NFtZAfFEb1z8ri2CdbDfTN\nahUluiXUvlzBKcGFD5qhZzqPCQpRm1/VLVqXTyXjMAC+jrtLJoRnYXB+01nr\nWy8w\r\n=DRQz\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIADHq2HatIfyvY1Hx6xeAbXx0Q7PCwPthccztyPdxKRqAiEAoEbN3UpzO9Gp/znfAGS9mIXdho1vfvpgX2vC/AMIlUg="}]},"maintainers":[{"name":"bonjourjohn","email":"nicolas.espiau@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/fixture-manager_1.0.0_1533031271834_0.8367099978096588"},"_hasShrinkwrap":false},"1.0.1":{"name":"@bonjourjohn/fixture-manager","version":"1.0.1","description":"Simple class allowing to manage fixture easily","main":"index.js","directories":{"test":"test"},"scripts":{"test":"mocha -b"},"repository":{"type":"git","url":"git+https://github.com/nicolasespiau/fixture-manager.git"},"keywords":["fixtures","mongodb","tests"],"author":{"name":"ESPIAU Nicolas"},"license":"ISC","bugs":{"url":"https://github.com/nicolasespiau/fixture-manager/issues"},"homepage":"https://github.com/nicolasespiau/fixture-manager#readme","devDependencies":{"mocha":"^5.2.0","mongodb":"^3.1.1","unit.js":"^2.0.0"},"gitHead":"24e6aad2a49cede773461dada32e63026f2fd96f","_id":"@bonjourjohn/fixture-manager@1.0.1","_npmVersion":"5.6.0","_nodeVersion":"9.9.0","_npmUser":{"name":"bonjourjohn","email":"nicolas.espiau@gmail.com"},"dist":{"integrity":"sha512-1ilu6aOzaz1pUT8V8t3GoKtdvjDSm4hvjNuMxFDkD4myofkYoo3Qh6ppM+Pp8kR59tx77Tj0LxUE5pUG/DgD/Q==","shasum":"3a85d144b3607f09dc8ef9726d431afea240113a","tarball":"https://registry.npmjs.org/@bonjourjohn/fixture-manager/-/fixture-manager-1.0.1.tgz","fileCount":6,"unpackedSize":15021,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbYFRQCRA9TVsSAnZWagAA6voP/0grCGBKbkIuqmiqKNTW\n9i9H8RCgWDIauVAfwpYsbOjIRU+Bk7OzSGsQFg9LQwERI8FEGUaT6ls7lNDM\nw3bvSnP1+46P2TI7l+mPkPRlMMRiC3YmDaqpkiK+4BJ7C/OEWG3CUd5eImKI\nq7W/mi8k+RAbi0OJzZ2SlxPog6oMFt8+/sEh36fgXEUhE3s6WSNWk6JpWPq3\nZhUBCK+lm0zZfG1alGCT0bWVShzOlz1QhRLr0OAiN8yl7W++KY8dMl7D8F1d\noH9Jj02yXIkSIL7GgkKdzJN5Bg7T+47ms5JzKIcXLykSCKg9XCAALBwzVigr\nQ5kiWfjHowV5l9utLN29WpD8wFURdxjkl9+dElNH0BIa6J2891DjMT6bqhdF\nAm6/3FXVM0PIpbCiDaVNbc/cp0dLoT+2IvXwl9gztwgggcScpCm+v1QUOfZZ\ndHv5HvEj27uCc9givewYxFnhzw2ASPBPfHfjIF5heLyJVei17+bB8jODl8ce\nz7zijL19TL1f8vVMtYRU+t/JIt7GdeC+9oowDgFFnupLnDrTwnoDeW8nvIWN\nYUjOcTXkXG7MlNpSmOl9U7cbqq5QFilSiupNH7BSEwjZFFBJqBoFyn/PPzV8\nmQPg7KkvHBXvX2ILSFgqZh0seCXrbzIQNmPHqcaw4vWJaqioSOD3yBW4bW72\nxedc\r\n=aj7D\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQC1naJ29+NrwBoMwXoKXYuzOKX0yxhp+4HDmNPkCqdnAAIgemk6Fh+pToA51CX743w1qr9M59X6RRs9pkV1bVAksTs="}]},"maintainers":[{"name":"bonjourjohn","email":"nicolas.espiau@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/fixture-manager_1.0.1_1533039696639_0.890208143311902"},"_hasShrinkwrap":false}},"time":{"created":"2018-07-31T10:01:11.558Z","1.0.0":"2018-07-31T10:01:11.927Z","modified":"2022-04-04T20:06:28.760Z","1.0.1":"2018-07-31T12:21:36.697Z"},"maintainers":[{"name":"bonjourjohn","email":"nicolas.espiau@gmail.com"}],"description":"Simple class allowing to manage fixture easily","homepage":"https://github.com/nicolasespiau/fixture-manager#readme","keywords":["fixtures","mongodb","tests"],"repository":{"type":"git","url":"git+https://github.com/nicolasespiau/fixture-manager.git"},"author":{"name":"ESPIAU Nicolas"},"bugs":{"url":"https://github.com/nicolasespiau/fixture-manager/issues"},"license":"ISC","readme":"# FIXTURE MANAGER\n\n## Purpose\n\nThis module provides a Fixture Loader class designed to manage fixtures easily: backuping collections, loading fixtures, restoring data.\n\n##  Quick start\n\n```javascript\nconst MongoClient = require('mongodb').MongoClient;\nconst Mclient = new MongoClient(SERVER, OPTIONS).connect();\nconst MDB = Mclient.db(DBNAME);\n\nconst fixtureLoaderClass = require('@bonjourjohn/fixture-manager');\nconst fixtureLoader = new fixtureLoaderClass(MDB);\n\n//load fixtures, execute before test script\nawait fixtureLoader.load(__dirname + '/fixtures/', [\"bikers\", \"old_ladies\"]);\n\n//access objects in loader\nfixtureLoader.get(\"foo\", 0); //get the first foo object in list\nfixtureLoader.get(\"bar\"); //get the while bar list\n\n//restore, execute after test script\nawait fixtureLoader.restore();\n```\n\n## Usage\n\n### Fixtures files\n\nYour fixtures must be stored in files following this structure:\n\n```javascript\n'use strict';\n\nlet ObjectId = require('mongodb').ObjectId; //only if you need to set id and access it from your tests\n\n_structure:_\nmodule.exports = {\n  \"collection\": \"bikers\",\n  \"objects\": [\n    {\n      \"_id\": ObjectId(),\n      \"field1\": \"Jackson\",\n      \"field2\": \"Teller\",\n      ...\n    },\n    ...\n  ]\n}\n```\n\n_example file: bikers.js_\n```javascript\n'use strict';\n\nlet ObjectId = require('mongodb').ObjectId; //only if you need to set id and access it from your tests\n\n\nmodule.exports = {\n  \"collection\": \"bikers\",\n  \"objects\": [\n    {\n      \"_id\": ObjectId(),\n      \"firstname\": \"Jackson\",\n      \"lastname\": \"Teller\",\n      \"email\": \"jax@samcro.org\"\n    },\n    {\n      \"_id\": ObjectId(),\n      \"firstname\": \"Clay\",\n      \"lastname\": \"Morrow\",\n      \"email\": \"clay@soamc.com\"\n    }\n  ]\n}\n```\n\n_example file: old_ladies.js_\n```javascript\n'use strict';\n\nlet ObjectId = require('mongodb').ObjectId; //only if you need to set id and access it from your tests\n\n\nmodule.exports = {\n  \"collection\": \"wives\",\n  \"objects\": [\n    {\n      \"_id\": ObjectId(),\n      \"firstname\": \"Tara\",\n      \"lastname\": \"Knowles\",\n      \"email\": \"t.knowles@st-thomas.com\"\n    },\n    {\n      \"_id\": ObjectId(),\n      \"firstname\": \"Gemma\",\n      \"lastname\": \"Morrow\",\n      \"email\": \"gemma.morrow@tm-garaga.com\"\n    }\n  ]\n}\n```\n\n## Testing\n\n### Requirements\n\nYou need a MongoDB and a Redis server running.\n\nMy choice is to use Docker to easy things.\nI recommend these images:\n - [MongoDB](https://hub.docker.com/_/mongo/)\n - [Redis](https://hub.docker.com/_/redis/)\n\n```shell\ndocker run --name database -p 27017:27017 -d mongo\ndocker run --name cache -p 6379:6379 -d redis:3.0.6-32bit\n```\n\nIf you already have a MongoDB server and a Redis server running localy then you don't need anything from Docker and you can ignore the instructions above.\n\nOnce everything is running, just run the tests:\n\n```shell\nnpm test\n```\n","readmeFilename":"readme.md"}