More changes for db migration
This commit is contained in:
parent
de0284e48a
commit
889dc02945
33 changed files with 740 additions and 100 deletions
|
@ -4,7 +4,7 @@ import debugname from 'debug';
|
|||
const debug = debugname('hostr:mongo');
|
||||
|
||||
/* eslint no-param-reassign: ["error", { "props": false }] */
|
||||
const configuredClient = new Promise((resolve, reject) => {
|
||||
export const mongo = new Promise((resolve, reject) => {
|
||||
debug('Connecting to Mongodb');
|
||||
return MongoClient.connect(process.env.MONGO_URL).then((client) => {
|
||||
debug('Successfully connected to Mongodb');
|
||||
|
@ -25,10 +25,10 @@ const configuredClient = new Promise((resolve, reject) => {
|
|||
debug(e);
|
||||
});
|
||||
|
||||
export default function mongo() {
|
||||
export default function () {
|
||||
return function* dbMiddleware(next) {
|
||||
try {
|
||||
this.db = yield configuredClient;
|
||||
this.db = yield mongo;
|
||||
} catch (e) {
|
||||
debug(e);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue