0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-13 06:32:39 +00:00

Both types of tests are now working

This commit is contained in:
Scott Tolksdorf
2017-01-06 00:48:52 -05:00
parent 5820564894
commit 66ca09b36d
5 changed files with 36 additions and 33 deletions

View File

@@ -6,13 +6,18 @@ const dbPath = process.env.MONGODB_URI || process.env.MONGOLAB_URI || 'mongodb:/
module.exports = {
connect : ()=>{
return new Promise((resolve, reject)=>{
mongoose.createConnection(dbPath,
if(mongoose.connection.readyState == 1){
console.log('already connected');
return resolve();
}
mongoose.connect(dbPath,
(err) => {
if(err){
console.log('Error : Could not connect to a Mongo Database.');
console.log(' If you are running locally, make sure mongodb.exe is running.');
return reject(err);
}
console.log('mongo connected.');
return resolve();
}
);