{"_id":"@danielscholl/mongo-lib","_rev":"2-d17ee97e081c3b743b22e9e83ad8d350","name":"@danielscholl/mongo-lib","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@danielscholl/mongo-lib","author":{"name":"Daniel Scholl"},"description":"A light wrapper for MongoDB","version":"1.0.0","private":false,"scripts":{"test":"tape test/*.spec.js","watch":"watch \"npm run -s test\" .","mongo:start":"docker run -it -d -p 27017:27017 --name mongo mongo","mongo:stop":"docker rm -f mongo"},"main":"../lib/db","dependencies":{"async":"^2.3.0","mongodb":"^2.2.25"},"devDependencies":{"dotenv":"^4.0.0","eslint":"^3.19.0","tape":"^4.6.3","watch":"^1.0.2"},"gitHead":"6547c8e01ee446fda54cd077a749352892b5201c","_id":"@danielscholl/mongo-lib@1.0.0","_npmVersion":"5.8.0","_nodeVersion":"8.10.0","_npmUser":{"name":"danielscholl","email":"degnome@me.com"},"dist":{"integrity":"sha512-pbyz12NvN+QGleXU8BgnLk+QLoa4hu5GmxyOgdTW1e/BzilfRerJAEnV2njTzc/sVX8GWimINMXdap9lzciUhA==","shasum":"5dd7926434f802469525b9fe9cc622ffdcabbc8f","tarball":"https://registry.npmjs.org/@danielscholl/mongo-lib/-/mongo-lib-1.0.0.tgz","fileCount":12,"unpackedSize":54027,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCIVYDt3qK7mOVP6PFCesUPRP3StCd0+S7uozkCA32XkQIhANgrKr/u1fwgkG+VNfyuYdtKZJjynJXOES8j1bhlZKWX"}]},"maintainers":[{"name":"danielscholl","email":"degnome@me.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/mongo-lib_1.0.0_1523461852694_0.7890573436558137"},"_hasShrinkwrap":false}},"time":{"created":"2018-04-11T15:50:52.631Z","1.0.0":"2018-04-11T15:50:52.801Z","modified":"2022-04-05T02:41:22.354Z"},"maintainers":[{"name":"danielscholl","email":"degnome@me.com"}],"description":"A light wrapper for MongoDB","author":{"name":"Daniel Scholl"},"readme":"# Wrapper Layer for MongoDB\n\nA simple wrapper for MongoDB.\n\n__Functionality:__\n\n- Query, which returns an array\n- First, Exists\n- Save, which upserts a record\n- Automatic table/db config\n- DB Manipulation (Create/Drop)\n\n\n## Usage\n\nInstall using\n\n```\nnpm install https://github.com/danielscholl/mongo-lib --save\n```\n\nTo use this in your code, just configure what you need:\n\n```javascript\nvar db = require(\"nongo-lib\");\ndb.connect({db : \"test\"}, (err,db) => {\n\n  //you now have access to all of your tables as properties on your db variable:\n  //so, assume there's a table called \"foo\" in your db...\n  db.foo.save({name : \"Mike\"}, (err,saved) => {\n\n    //output the generated ID\n    console.log(saved.id);\n  });\n\n});\n```\n\nEach table on your DB object is a full-blown Mongo collection, so you can step outside the abstraction at any point:\n\n```javascript\ndb.connect({db : \"test\"}, (err,db) => {\n\n  //this is a ReQL query\n  db.foo.eqJoin('bar_id', db.bar).run(conn, function(err,cursor){\n\n    //run the joined action and do something interesting\n    cursor.toArray(function(err,array){\n      //use the array...\n\n      //be sure to close the connection!\n      conn.close();\n    });\n\n  });\n});\n\n```\n\nIn addition you can do all kinds of fun things, like...\n\n```javascript\n//installation of the DB and tables\ndb.connect({db : \"test\"}, (err, db) => {\n  db.install(['foo', 'bar'], (err,result) => {\n    //tables should be installed now...\n  });\n});\n\n//add a secondary index\ndb.connect({db : \"test\"}, (err,db) => {\n  db.foo.index(\"email\", function(err, indexed){\n    //indexed == true;\n  });\n});\n```\n\n## Basic Queries\n\n```javascript\ndb.connect({db : \"test\", (err, db) => {\n\n  db.foo.query({category : \"beer\"}, (err, beers) => {\n    //beers is an array, so have at it\n  });\n\n  db.foo.first({email : \"john.doe@mail.com\"}, (err, john) => {\n    //hi John\n  });\n\n  db.foo.exists({name : \"bill\"}, (err, exists) => {\n    //exists will tell you if it's there\n  });\n\n  db.foo.destroy({id : \"some-id\"}, (err, destroyed) => {\n    //destroyed will be true if something was deleted\n  });\n\n  db.foo.destroyAll((err, destroyed) => {\n    //destroyed is the count of records whacked\n  });\n\n  db.foo.updateOnly({name : \"Stevie\"}, \"some-id\", (err, result) => {\n    //save will do a full swap of the document, updateOnly will partially update\n    //a document so you need to pass the id along\n    //result will be true if an update happened\n  });\n\n});\n\n```","readmeFilename":"README.md"}