2013-10-03 2 views
0

콜렉션이 존재하지 않으면 생성하고 데이터로 미리 채우기 만한다는 간단한 검사입니다. 이 내 로컬 상자에서 제대로 작동하고 coll "존재하지 않는 경우 오류를 throw합니다 db.collection 호출에 설정된"엄격한 "플래그에 따라 달라집니다. 그러나 Heroku에서는 작동하지 않습니다.Heroku에서 strict 플래그가 작동하지 않는 db.collection 사용

mongo.Db.connect(mongoUri, function (err, db) { 
    if (!err) 
    { 
    console.log("Connected to Database") 
    db.collection('collectionName', {strict:true}, function(er, collection) { 
     if (!er) 
     { 
     console.log("Collection opened, ready for use!") 
     } else { 
     console.log("DATA DOES NOT EXIST, PREPOPULATING") 
     populateDB(); 
     } 
    }); 
    } else { 
    console.log("Error connecting to database: " + err) 
    } 
}); 

package.json

{ 
    "name": "appname", 
    "description": "Application", 
    "version": "0.0.1", 
    "private": true, 
    "dependencies": { 
     "express": "3.x", 
     "mongodb": "1.3.x", 
     "socket.io": "0.9.10" 
    }, 
    "engines": { 
     "node": "0.8.4", 
     "npm": "1.1.49" 
    } 
} 

답변

0

신경 끄시 일 - package.json 파일의 버전 0.10.x 그에게 나는 업데이트 노드 그것을 고칠 것 같았다.

관련 문제