@drifted/db 0.0.6 → 0.0.10

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drifted/db",
3
- "version": "0.0.6",
3
+ "version": "0.0.10",
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": {
package/pg/index.js ADDED
@@ -0,0 +1,6 @@
1
+ const path = require('path');
2
+ require('@drifted/env');
3
+ var initialize = require(path.join(__dirname, 'initialize'));
4
+ var pool = initialize(process.env.POSTGRES_URL);
5
+
6
+ module.exports = pool;
@@ -0,0 +1,27 @@
1
+ const { Pool } = require('pg');
2
+ const path = require('path');
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
+
12
+ function initialize(url) {
13
+ if (url == undefined && process.env.POSTGRES_URL != undefined) {
14
+ url = process.env.POSTGRES_URL;
15
+ }
16
+
17
+ const pool = new Pool({
18
+ connectionString: url
19
+ });
20
+
21
+ return pool
22
+ }
23
+
24
+ module.exports = initialize;
25
+
26
+
27
+