@drifted/db 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,11 +1,24 @@
1
- const mongoose = require('mongoose');
1
+ const mongo = require('mongo');
2
2
  const path = require('path');
3
3
 
4
+
5
+ // The mongoose initalizer returns a connection. This one just
6
+ // returns a new client that can be connected and disconnected
7
+ // and not held open. I would prefer to have then behave the
8
+ // same way and just return but I'm not sure how to handle the
9
+ // async. Maybe I could just make both async? Not ideal.
10
+
11
+
4
12
  function initialize(url) {
5
13
  if (url == undefined && process.env.MONGO_URL != undefined) {
6
14
  url = process.env.MONGO_URL;
7
15
  }
8
- return mongoose.connect(url)
16
+ const client = new MongoClient(url);
17
+
18
+ return client
9
19
  }
10
20
 
11
21
  module.exports = initialize;
22
+
23
+
24
+
@@ -0,0 +1,6 @@
1
+ const path = require('path');
2
+ require('@drifted/env');
3
+ var initialize = require(path.join(__dirname, 'initialize'));
4
+
5
+ initialize(process.env.MONGO_URL).
6
+ catch(console.eror);
@@ -0,0 +1,11 @@
1
+ const mongoose = require('mongoose');
2
+ const path = require('path');
3
+
4
+ function initialize(url) {
5
+ if (url == undefined && process.env.MONGO_URL != undefined) {
6
+ url = process.env.MONGO_URL;
7
+ }
8
+ return mongoose.connect(url)
9
+ }
10
+
11
+ module.exports = initialize;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drifted/db",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "description": "db module that allows me to establish conventions between projects",
5
5
  "homepage": "https://github.com/driftless-group/db#readme",
6
6
  "bugs": {