Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion env.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"MONGO_HOSTNAME": {
"type": "string",
"default": "mongodb://rems-admin-pims-root:rems-admin-pims-password@localhost:27017",
Comment thread
smalho01 marked this conversation as resolved.
"default": "mongodb://rems-user:pass@127.0.0.1:27017",
"required": true
},
"MONGO_DB_NAME": {
Expand Down
7 changes: 6 additions & 1 deletion mongo-init.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
// Create Databases
const dbPims = db.getSiblingDB('pims');
const dbRemsAdmin = db.getSiblingDB('remsadmin');

dbRemsAdmin.createUser({ user: "rems-user",
pwd: "pass",
Comment thread
smalho01 marked this conversation as resolved.
roles: [
{ role: "readWrite", db: "remsadmin" }
]
})
// Create Collections
dbPims.createCollection('pims-tmp');
dbRemsAdmin.createCollection('remsadmin-tmp');
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"moment": "^2.24.0",
"moment-timezone": "^0.5.40",
"mongodb": "^4.12.1",
"mongoose": "^6.9.2",
"morgan": "^1.9.1",
"tingodb": "^0.6.1",
"uid": "^2.0.1",
Expand Down
7 changes: 4 additions & 3 deletions src/lib/MongoDatabase.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Database } from './Database';
import * as mongoDB from 'mongodb';

import mongoose from 'mongoose';
export class MongoDatabase extends Database {
options: any;
db_name: string;
Expand All @@ -16,8 +16,9 @@ export class MongoDatabase extends Database {
new Promise(resolve => {
// Connect to mongo
console.log('MongoDatabase connect: ' + this.location);
this.client = new mongoDB.MongoClient(this.location);
const dbString = `${this.location}/${this.db_name}`;
this.client = new mongoose.mongo.MongoClient(dbString);
this.database = this.client.db(this.db_name);
return resolve(this.client.connect());
Comment thread
smalho01 marked this conversation as resolved.
return resolve(mongoose.connect(dbString));
});
}