Skip to content

Instantly share code, notes, and snippets.

@aramkoukia
Created December 28, 2017 21:51
Show Gist options
  • Select an option

  • Save aramkoukia/4447a6752c2bd8e9e52fe83bd74c3e3d to your computer and use it in GitHub Desktop.

Select an option

Save aramkoukia/4447a6752c2bd8e9e52fe83bd74c3e3d to your computer and use it in GitHub Desktop.
const mongoose = require('mongoose');
/**
* Set to Node.js native promises
* Per http://mongoosejs.com/docs/promises.html
*/
mongoose.Promise = global.Promise;
// Cosmos DB Connection String
// eslint-disable-next-line max-len
const mongoUri = `mongodb://${process.env.COSMOSDB_ACCOUNT}:${process.env.COSMOSDB_KEY}@${
process.env.COSMOSDB_ACCOUNT
}.documents.azure.com:${process.env.COSMOSDB_PORT}/${process.env.COSMOSDB_DB}?ssl=true`;
// &replicaSet=globaldb`;
// Local MongoDB Connection String
// const mongoUri = `mongodb://localhost:27017/connect-todoes`;
function connect() {
mongoose.set('debug', true);
return mongoose.connect(mongoUri, { useMongoClient: true });
}
module.exports = {
connect,
mongoose
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment