{"bugs":{"url":"https://github.com/mafintosh/gridjs/issues"},"dist":{"shasum":"18a10dab54a28e567d5e4844c737cb8428e13736","tarball":"https://registry.npmjs.org/gridjs/-/gridjs-0.1.0.tgz","integrity":"sha512-t6GO7/1F3WxYBQLoU1HHki654T0VW9Ppl8WbSxtMY3ZEJ5uNnLWp2Ck4osLQgyqtA/sYwq3aWuiD32zXiqAQYg==","signatures":[{"sig":"MEQCIFXYdiPYlbZBjaQhSqYcnz4OkxbtznSVfmuj8I/ukhnHAiAoJVwR+4Ojhe57C4L17pnIUojWfXY8CkTwUQyJKpTxpg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"name":"gridjs","_from":".","readme":"# gridjs\n\nA GridFS module that is easy to use and [mongojs](https://github.com/mafintosh/mongjs) compliant.\nIt is available through npm\n\n\tnpm install gridjs\n\n## Usage\n\nIt is easy to use\n\n### Connecting to Mongo/GridFS\n\nTo get started pass a connection string or mongojs instance to the gridjs constructor\n\n``` js\nvar gridjs = require('gridjs');\nvar fs = require('fs');\n\nvar gs = gridjs('my-connection-string');\n\n// or using a mongojs instance\n\nvar db = mongojs('my-connection-string');\nvar gs = gridjs(db);\n\n// or using a node-mongodb-native instance\n\nmongodb.Db.connect(connectionString, function(err, db) {\n\tvar gs = gridjs(db);\n});\n```\n\n### Writing files\n\nWriting files using gridjs is a simple as piping to `gs.createWriteStream(filename)`\nwhich returns a [streams2 WriteStream](http://nodejs.org/api/stream.html#stream_class_stream_writable)\n\n``` js\nfs.createReadStream('any-file').pipe(gs.createWriteStream('gridfs-filename'));\n```\n\nAlternatively if you have the entire file as a single buffer you can use `gs.write(filename, buffer, [enc], callback)`\n\n``` js\ngs.write('test-file', new Buffer('hello world'), function(err) {\n\tconsole.log('file is written', err);\n});\n```\n\n### Reading files\n\nSimilary when reading files you just pipe from `gs.createReadStream(filename, [options])`\nwhich returns a [streams2 ReadStream](http://nodejs.org/api/stream.html#stream_class_stream_readable)\n\n``` js\ngs.createReadStream('gridfs-filename').pipe(process.stdout);\n```\n\nThere is also a `gs.read(filename, [enc], callback)` shorthand if you want to read the entire file into a buffer\n\n``` js\ngs.read('test-file', function(err, buffer) {\n\tconsole.log('file is read', buffer);\n});\n```","_npmUser":{"name":"mafintosh","email":"mathiasbuus@gmail.com"},"keywords":["gridfs","grid","gridstore","fs","mongo"],"repository":{"url":"git://github.com/mafintosh/gridjs.git","type":"git"},"_npmVersion":"1.3.8","description":"GridFS that is easy to use and mongojs compliant","directories":{},"maintainers":[{"name":"mafintosh","email":"mathiasbuus@gmail.com"}],"dependencies":{"thunky":"~0.1.0","mongodb":"~1.3.19","readable-stream":"~1.1.8"},"readmeFilename":"README.md","_id":"gridjs@0.1.0","version":"0.1.0"}