title: Gridfs and mongoose file upload
body: <p>I have ran into a problem with gridfs file upload.
  Basically I get this bizzare error and I have yet not found solution for solving this problem.</p>
  
  <p>Here is my code that should deal with file upload:</p>
  
  <pre><code>var path = require('path');
  var router = require('express').Router();
  var mongoose = require('mongoose');
  var serverConfig = require('../config.js');
  var multiparty = require('connect-multiparty')();
  var fs = require('fs');
  var GridFs = require('gridfs-stream');
  
  
  var db = mongoose.connection.db;
  var mongoDriver = mongoose.mongo;
  var gfs = new Gridfs(db, mongoDriver);
  
  router.post('/upload', multiparty, function(req, res){
      console.log("file was posted");
      var writestream = gfs.createWriteStream({
          filename: req.files.file.name + Date.now(),
          mode: 'w',
          content_type: req.files.file.mimetype,
          metadata: req.body
      });
      fs.createReadStream(req.files.file.path).pipe(writestream);
      writestream.on('close', function(file){
          res.status(200).json(file);
      })
  })
  </code></pre>
  
  <p>When trying to run my code, I get this error: </p>
  
  <pre><code>if (!db) throw new Error('missing db argument\nnew Grid(db, mongo)');
             ^
  
  Error: missing db argument
  new Grid(db, mongo)
  </code></pre>
  
  <p>Im using Mongoose version 4.11.12 and Gridfs-stream version 1.1.1 <br>
  <strong>Does anybody know what should be done to get this thing working?</strong></p>