title: How can i use MongoDB with Cloud Functions for Firebase?
body: <p>I want to use Cloud Functions for Firebase and MongoDB. The problem is I don't know how to connect my Mongo database with Cloud Functions. My database is deployed at matlab. 
  I made this schema:</p>
  
  <pre><code>var mongoose = require('mongoose')
  var Schema = mongoose.Schema
  
  var patientSchema = new Schema({
  
      name: {
          type: String,
          required : true,
      },
  
      disease:{
          type: String,
          required : true, 
      },
  
      medication_provided: {
          type: String,
          required : true,
      },
  
      date : {
          type : Date,
      }
  })
  
  const patient = mongoose.model('patientInfo', patientSchema)
  module.exports = patient
  </code></pre>
  
  <p>Then I require my schema in project index.js file, and export a function called getAllPatient.</p>
  
  <pre><code>const patient = require('../Patient')
  const functions = require('firebase-functions');
  const mongoose = require('mongoose')
  
  mongoose.connect('mongodb://patient:patient123@ds139869.mlab.com:39869/patient',{useMongoClient: true})
  exports.getAllPatient = functions.https.onRequest((request, response) =&gt; {
      patient.find({}).then((data) =&gt; {
          response.send(data)
      })
  })
  </code></pre>
  
  <p>but gives me an error that "Error: could not handle the request"</p>