@drifted/db 0.0.3 → 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.
- package/mongo/initialize.js +15 -2
- package/mongoose/index.js +6 -0
- package/mongoose/initialize.js +11 -0
- package/package.json +1 -1
- package/redis/index.js +5 -1
package/mongo/initialize.js
CHANGED
|
@@ -1,11 +1,24 @@
|
|
|
1
|
-
const
|
|
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
|
-
|
|
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,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
package/redis/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
if (process.env.REDIS_URL == undefined) {
|
|
4
|
+
require('@drifted/env');
|
|
5
|
+
}
|
|
3
6
|
var initialize = require(path.join(__dirname, 'initialize'));
|
|
4
7
|
|
|
8
|
+
|
|
5
9
|
var client = initialize({url: process.env.REDIS_URL});
|
|
6
10
|
|
|
7
11
|
async function connect() {
|