2017-09-12 1 views
-1

(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 
 
};

+0

두 번이, 당신은 몽구스 변수를 선언하는 몇 가지 문제, murikowski에 의해 지적 잘못 선언 구문이 있습니다 시도, 'profileSchema 선언 할 것으로 보인다 결코 (또는 어쩌면 우리는 돈 그것을 여기에서 보지 마라). 나는이 질문이 몽구스 연결을하는 것과 관련이 없다고 생각한다. –

답변

0

스크립트를 깰 수 귀하의 첫 번째 라인!

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

const mongoose = require('mongoose'); 
+0

우선 내 대본을보고 많은 감사드립니다. 스크립트를 변경 한 후 노드 cmd는 module.js를 제공합니다 : 529 오류가 발생했습니다 ... 어떤 생각입니까? – Tichel