(Queries hang when using mongoose.createConnection() vs mongoose.connect()을 얻고 경험 unfortunataly 부족으로 내가 할 수있는'수 t mongoose.createConnection로 작동하는 연결을 얻을.'는 t는 많은 주제에도 불구하고 작업 익스프레스 몽구스 연결
는 언급 연결된 I 중 하나에 영감을 결과없이 내 스크립트 만 변경하기 시작했다.
//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
};
두 번이, 당신은 몽구스 변수를 선언하는 몇 가지 문제, murikowski에 의해 지적 잘못 선언 구문이 있습니다 시도, 'profileSchema 선언 할 것으로 보인다 결코 (또는 어쩌면 우리는 돈 그것을 여기에서 보지 마라). 나는이 질문이 몽구스 연결을하는 것과 관련이 없다고 생각한다. –