-1

despite the many topics (Queries hang when using mongoose.createConnection() vs mongoose.connect() and with unfortunataly a lack of experience I can 't get a working connection with mongoose.createConnection.

Inspired on one of the mentioned linked I started to change my script but without result.

//my db.js

const mongoose = require('mongoose'), db;

db = mongoose.createConnection = ("mongodb://localhost:27017/myApp",
{ "auth": { "authSource": "admin" }, "user": "admin1234", "pass": "abcd" }); 

require('./profiles');

//profiles.js

const mongoose = require('mongoose');

const logFile = new mongoose.Schema ({});
//etc etc

mongoose.model('Profile', profileSchema);

// routepages index.js

const express = require('express')';
const router = express.Router();
const ctrlProfiles('../controller/profiles');

router
//some routes 

module.exports = router;


//controllers profiles.js
const mongoose = require('db'),

const Prof = mongoose.model('Profile');

const profileCreate = function (req,res) {};

module.exports = {
profileCreate 
};
Tichel
  • 481
  • 2
  • 10
  • 24
  • There are a few issues with this, you are declaring the mongoose variable twice, wrong declaration syntax as pointed out by murikowski, profileSchema never seems to be declared (or maybe we don't see it here). I don't think this question has much to do with getting a working mongoose connection. – Nicola Pedretti Sep 12 '17 at 19:17

1 Answers1

0

Your first Line may break your Script!

const mongoose = require('mongoose'), db;

try

const mongoose = require('mongoose');
murikowski
  • 26
  • 2
  • First of all many thanks for looking at my script. After changing the script the node cmd gives a module.js: 529 error throw err.. any idea? – Tichel Sep 14 '17 at 13:59